@@ -40,12 +40,9 @@ void testArraySubscripts(int idx, int *p, int **pp) {
40
40
// expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
41
41
// expected-warning@-2{{'pp' is an unsafe pointer used for buffer access}}
42
42
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}}
49
46
);
50
47
51
48
if (p[3 ]) { // expected-note{{used in buffer access here}}
@@ -65,13 +62,9 @@ void testArraySubscripts(int idx, int *p, int **pp) {
65
62
int b[10 ][10 ]; // expected-warning{{'b' is an unsafe buffer that does not perform bounds checks}}
66
63
67
64
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}}
75
68
76
69
// Not to warn when index is zero
77
70
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]
108
101
foo (p[1 ], 1 [p], p[-1 ], // expected-note3{{used in buffer access here}}
109
102
q[1 ], 1 [q], q[-1 ], // expected-note3{{used in buffer access here}}
110
103
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
113
105
);
114
106
}
115
107
@@ -128,25 +120,25 @@ T_t funRetT();
128
120
T_t * funRetTStar ();
129
121
130
122
void 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 ],
132
124
sp->b [1 ], // expected-warning{{unsafe buffer access}}
133
- sp->c .a [1 ], // expected-warning{{unsafe buffer access}}
125
+ sp->c .a [1 ],
134
126
sp->c .b [1 ], // expected-warning{{unsafe buffer access}}
135
- s.a [1 ], // expected-warning{{unsafe buffer access}}
127
+ s.a [1 ],
136
128
s.b [1 ], // expected-warning{{unsafe buffer access}}
137
- s.c .a [1 ], // expected-warning{{unsafe buffer access}}
129
+ s.c .a [1 ],
138
130
s.c .b [1 ], // expected-warning{{unsafe buffer access}}
139
- sp2->a [1 ], // expected-warning{{unsafe buffer access}}
131
+ sp2->a [1 ],
140
132
sp2->b [1 ], // expected-warning{{unsafe buffer access}}
141
- sp2->c .a [1 ], // expected-warning{{unsafe buffer access}}
133
+ sp2->c .a [1 ],
142
134
sp2->c .b [1 ], // expected-warning{{unsafe buffer access}}
143
- s2.a [1 ], // expected-warning{{unsafe buffer access}}
135
+ s2.a [1 ],
144
136
s2.b [1 ], // expected-warning{{unsafe buffer access}}
145
- s2.c .a [1 ], // expected-warning{{unsafe buffer access}}
137
+ s2.c .a [1 ],
146
138
s2.c .b [1 ], // expected-warning{{unsafe buffer access}}
147
- funRetT ().a [1 ], // expected-warning{{unsafe buffer access}}
139
+ funRetT ().a [1 ],
148
140
funRetT ().b [1 ], // expected-warning{{unsafe buffer access}}
149
- funRetTStar ()->a [1 ], // expected-warning{{unsafe buffer access}}
141
+ funRetTStar ()->a [1 ],
150
142
funRetTStar ()->b [1 ] // expected-warning{{unsafe buffer access}}
151
143
);
152
144
}
@@ -213,7 +205,6 @@ void testTypedefs(T_ptr_t p) {
213
205
// expected-warning@-1{{'p' is an unsafe pointer used for buffer access}}
214
206
foo (p[1 ], // expected-note{{used in buffer access here}}
215
207
p[1 ].a [1 ], // expected-note{{used in buffer access here}}
216
- // expected-warning@-1{{unsafe buffer access}}
217
208
p[1 ].b [1 ] // expected-note{{used in buffer access here}}
218
209
// expected-warning@-1{{unsafe buffer access}}
219
210
);
@@ -223,10 +214,9 @@ template<typename T, int N> T f(T t, T * pt, T a[N], T (&b)[N]) {
223
214
// expected-warning@-1{{'t' is an unsafe pointer used for buffer access}}
224
215
// expected-warning@-2{{'pt' is an unsafe pointer used for buffer access}}
225
216
// 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}}
227
217
foo (pt[1 ], // expected-note{{used in buffer access here}}
228
218
a[1 ], // expected-note{{used in buffer access here}}
229
- b[1 ]); // expected-note{{used in buffer access here}}
219
+ b[1 ]);
230
220
return &t[1 ]; // expected-note{{used in buffer access here}}
231
221
}
232
222
@@ -366,17 +356,15 @@ int testArrayAccesses(int n, int idx) {
366
356
// expected-warning@-1{{'cArr' is an unsafe buffer that does not perform bounds checks}}
367
357
int d = cArr[0 ][0 ];
368
358
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}}
373
361
foo (cPtr);
374
362
375
363
// Typdefs
376
364
typedef int A[3 ];
377
365
const A tArr = {4 , 5 , 6 };
378
366
foo (tArr[0 ], tArr[1 ]);
379
- return cArr[0 ][1 ]; // expected-warning{{unsafe buffer access}}
367
+ return cArr[0 ][1 ];
380
368
}
381
369
382
370
void testArrayPtrArithmetic (int x[]) { // expected-warning{{'x' is an unsafe pointer used for buffer access}}
0 commit comments