@@ -40,12 +40,9 @@ void testArraySubscripts(int idx, int *p, int **pp) {
4040// expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
4141// expected-warning@-2{{'pp' is an unsafe pointer used for buffer access}}
4242 foo (p[1 ], // expected-note{{used in buffer access here}}
43- pp[1 ][1 ], // expected-note{{used in buffer access here}}
44- // expected-warning@-1{{unsafe buffer access}}
45- 1 [1 [pp]], // expected-note{{used in buffer access here}}
46- // expected-warning@-1{{unsafe buffer access}}
47- 1 [pp][1 ] // expected-note{{used in buffer access here}}
48- // expected-warning@-1{{unsafe buffer access}}
43+ pp[1 ][1 ], // expected-note2{{used in buffer access here}}
44+ 1 [1 [pp]], // expected-note2{{used in buffer access here}}
45+ 1 [pp][1 ] // expected-note2{{used in buffer access here}}
4946 );
5047
5148 if (p[3 ]) { // expected-note{{used in buffer access here}}
@@ -65,13 +62,9 @@ void testArraySubscripts(int idx, int *p, int **pp) {
6562 int b[10 ][10 ]; // expected-warning{{'b' is an unsafe buffer that does not perform bounds checks}}
6663
6764 foo (a[idx], idx[a], // expected-note2{{used in buffer access here}}
68- b[idx][idx + 1 ], // expected-warning{{unsafe buffer access}}
69- // expected-note@-1{{used in buffer access here}}
70- (idx + 1 )[b][idx],// expected-warning{{unsafe buffer access}}
71- // expected-note@-1{{used in buffer access here}}
72- (idx + 1 )[idx[b]]);
73- // expected-warning@-1{{unsafe buffer access}}
74- // expected-note@-2{{used in buffer access here}}
65+ b[idx][idx + 1 ], // expected-note2{{used in buffer access here}}
66+ (idx + 1 )[b][idx],// expected-note2{{used in buffer access here}}
67+ (idx + 1 )[idx[b]]); // expected-note2{{used in buffer access here}}
7568
7669 // Not to warn when index is zero
7770 foo (p[0 ], pp[0 ][0 ], 0 [0 [pp]], 0 [pp][0 ],
@@ -108,8 +101,7 @@ void testQualifiedParameters(const int * p, const int * const q, const int a[10]
108101 foo (p[1 ], 1 [p], p[-1 ], // expected-note3{{used in buffer access here}}
109102 q[1 ], 1 [q], q[-1 ], // expected-note3{{used in buffer access here}}
110103 a[1 ], // expected-note{{used in buffer access here}} `a` is of pointer type
111- b[1 ][2 ] // expected-note{{used in buffer access here}} `b[1]` is of array type
112- // expected-warning@-1{{unsafe buffer access}}
104+ b[1 ][2 ] // expected-note2{{used in buffer access here}} `b[1]` is of array type
113105 );
114106}
115107
@@ -128,25 +120,25 @@ T_t funRetT();
128120T_t * funRetTStar ();
129121
130122void testStructMembers (struct T * sp, struct T s, T_t * sp2, T_t s2) {
131- foo (sp->a [1 ], // expected-warning{{unsafe buffer access}}
123+ foo (sp->a [1 ],
132124 sp->b [1 ], // expected-warning{{unsafe buffer access}}
133- sp->c .a [1 ], // expected-warning{{unsafe buffer access}}
125+ sp->c .a [1 ],
134126 sp->c .b [1 ], // expected-warning{{unsafe buffer access}}
135- s.a [1 ], // expected-warning{{unsafe buffer access}}
127+ s.a [1 ],
136128 s.b [1 ], // expected-warning{{unsafe buffer access}}
137- s.c .a [1 ], // expected-warning{{unsafe buffer access}}
129+ s.c .a [1 ],
138130 s.c .b [1 ], // expected-warning{{unsafe buffer access}}
139- sp2->a [1 ], // expected-warning{{unsafe buffer access}}
131+ sp2->a [1 ],
140132 sp2->b [1 ], // expected-warning{{unsafe buffer access}}
141- sp2->c .a [1 ], // expected-warning{{unsafe buffer access}}
133+ sp2->c .a [1 ],
142134 sp2->c .b [1 ], // expected-warning{{unsafe buffer access}}
143- s2.a [1 ], // expected-warning{{unsafe buffer access}}
135+ s2.a [1 ],
144136 s2.b [1 ], // expected-warning{{unsafe buffer access}}
145- s2.c .a [1 ], // expected-warning{{unsafe buffer access}}
137+ s2.c .a [1 ],
146138 s2.c .b [1 ], // expected-warning{{unsafe buffer access}}
147- funRetT ().a [1 ], // expected-warning{{unsafe buffer access}}
139+ funRetT ().a [1 ],
148140 funRetT ().b [1 ], // expected-warning{{unsafe buffer access}}
149- funRetTStar ()->a [1 ], // expected-warning{{unsafe buffer access}}
141+ funRetTStar ()->a [1 ],
150142 funRetTStar ()->b [1 ] // expected-warning{{unsafe buffer access}}
151143 );
152144}
@@ -213,7 +205,6 @@ void testTypedefs(T_ptr_t p) {
213205 // expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
214206 foo (p[1 ], // expected-note{{used in buffer access here}}
215207 p[1 ].a [1 ], // expected-note{{used in buffer access here}}
216- // expected-warning@-1{{unsafe buffer access}}
217208 p[1 ].b [1 ] // expected-note{{used in buffer access here}}
218209 // expected-warning@-1{{unsafe buffer access}}
219210 );
@@ -223,10 +214,9 @@ template<typename T, int N> T f(T t, T * pt, T a[N], T (&b)[N]) {
223214 // expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
224215 // expected-warning@-2{{'pt' is an unsafe pointer used for buffer access}}
225216 // expected-warning@-3{{'a' is an unsafe pointer used for buffer access}}
226- // expected-warning@-4{{'b' is an unsafe buffer that does not perform bounds checks}}
227217 foo (pt[1 ], // expected-note{{used in buffer access here}}
228218 a[1 ], // expected-note{{used in buffer access here}}
229- b[1 ]); // expected-note{{used in buffer access here}}
219+ b[1 ]);
230220 return &t[1 ]; // expected-note{{used in buffer access here}}
231221}
232222
@@ -366,17 +356,15 @@ int testArrayAccesses(int n, int idx) {
366356 // expected-warning@-1{{'cArr' is an unsafe buffer that does not perform bounds checks}}
367357 int d = cArr[0 ][0 ];
368358 foo (cArr[0 ][0 ]);
369- foo (cArr[idx][idx + 1 ]); // expected-note{{used in buffer access here}}
370- // expected-warning@-1{{unsafe buffer access}}
371- auto cPtr = cArr[idx][idx * 2 ]; // expected-note{{used in buffer access here}}
372- // expected-warning@-1{{unsafe buffer access}}
359+ foo (cArr[idx][idx + 1 ]); // expected-note2{{used in buffer access here}}
360+ auto cPtr = cArr[idx][idx * 2 ]; // expected-note2{{used in buffer access here}}
373361 foo (cPtr);
374362
375363 // Typdefs
376364 typedef int A[3 ];
377365 const A tArr = {4 , 5 , 6 };
378366 foo (tArr[0 ], tArr[1 ]);
379- return cArr[0 ][1 ]; // expected-warning{{unsafe buffer access}}
367+ return cArr[0 ][1 ];
380368}
381369
382370void testArrayPtrArithmetic (int x[]) { // expected-warning{{'x' is an unsafe pointer used for buffer access}}
0 commit comments