Commit b2b6919
committed
Diagnose potential size confusion with VLA params
With Clang starting to support bounds safety checking annotations,
we've begun to dabble in late parsing of function parameters so that
an earlier parameter can refer to a later parameter by name. However,
one situation where this can cause a problem is if the earlier
parameter is actually referencing a variable from an outer scope.
To help identify those situations, this introduces a new diagnostic
-Wvla-potential-size-confusion (grouped under -Wvla). This diagnoses
code like:
int n;
void func(int array[n], int n);
to let the user know that the 'n' in 'array[n]' references the file
scope variable and not the parameter.1 parent cd4c10a commit b2b6919
File tree
5 files changed
+152
-1
lines changed- clang
- docs
- include/clang/Basic
- lib/Sema
- test/Sema
5 files changed
+152
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
222 | 222 | | |
223 | 223 | | |
224 | 224 | | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
225 | 230 | | |
226 | 231 | | |
227 | 232 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
936 | 936 | | |
937 | 937 | | |
938 | 938 | | |
939 | | - | |
| 939 | + | |
| 940 | + | |
940 | 941 | | |
941 | 942 | | |
942 | 943 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
173 | 180 | | |
174 | 181 | | |
175 | 182 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
| |||
10333 | 10334 | | |
10334 | 10335 | | |
10335 | 10336 | | |
| 10337 | + | |
| 10338 | + | |
| 10339 | + | |
| 10340 | + | |
| 10341 | + | |
| 10342 | + | |
| 10343 | + | |
| 10344 | + | |
| 10345 | + | |
| 10346 | + | |
| 10347 | + | |
| 10348 | + | |
| 10349 | + | |
| 10350 | + | |
| 10351 | + | |
| 10352 | + | |
| 10353 | + | |
| 10354 | + | |
| 10355 | + | |
| 10356 | + | |
| 10357 | + | |
| 10358 | + | |
| 10359 | + | |
| 10360 | + | |
| 10361 | + | |
| 10362 | + | |
| 10363 | + | |
| 10364 | + | |
| 10365 | + | |
| 10366 | + | |
| 10367 | + | |
| 10368 | + | |
| 10369 | + | |
| 10370 | + | |
| 10371 | + | |
| 10372 | + | |
| 10373 | + | |
| 10374 | + | |
| 10375 | + | |
| 10376 | + | |
| 10377 | + | |
| 10378 | + | |
| 10379 | + | |
| 10380 | + | |
| 10381 | + | |
| 10382 | + | |
| 10383 | + | |
| 10384 | + | |
| 10385 | + | |
| 10386 | + | |
| 10387 | + | |
| 10388 | + | |
| 10389 | + | |
| 10390 | + | |
| 10391 | + | |
| 10392 | + | |
| 10393 | + | |
| 10394 | + | |
| 10395 | + | |
| 10396 | + | |
| 10397 | + | |
| 10398 | + | |
| 10399 | + | |
| 10400 | + | |
| 10401 | + | |
| 10402 | + | |
| 10403 | + | |
| 10404 | + | |
| 10405 | + | |
10336 | 10406 | | |
10337 | 10407 | | |
10338 | 10408 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
0 commit comments