blob: 45e713b6880abc3a93baec1629b59772b3c30dd2 [file] [log] [blame]
Ted Kremenek540dda62011-08-23 20:30:50 +00001// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,experimental.unix,experimental.security.ArrayBound -analyzer-store=region -verify %s
2// XFAIL: *
3
4// Once we better handle modeling of sizes of VLAs, we can pull this back
5// into outofbound.c.
6
7void sizeof_vla(int a) {
8 if (a == 5) {
9 char x[a];
10 int y[sizeof(x)];
11 y[4] = 4; // no-warning
12 y[5] = 5; // expected-warning{{out-of-bound}}
13 }
14}
15
16void sizeof_vla_2(int a) {
17 if (a == 5) {
18 char x[a];
19 int y[sizeof(x) / sizeof(char)];
20 y[4] = 4; // no-warning
21 y[5] = 5; // expected-warning{{out-of-bound}}
22 }
23}
24
25void sizeof_vla_3(int a) {
26 if (a == 5) {
27 char x[a];
28 int y[sizeof(*&*&*&x)];
29 y[4] = 4; // no-warning
30 y[5] = 5; // expected-warning{{out-of-bound}}
31 }
32}