Reverting merge from trunk
[official-gcc.git] / gcc / testsuite / c-c++-common / ubsan / vla-1.c
blob6c1d81e9d22022041afe1099fcd6880e28f73ebd
1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=vla-bound -w" } */
4 static int
5 bar (void)
7 return -42;
10 typedef long int V;
11 int
12 main (void)
14 int x = -1;
15 double di = -3.2;
16 V v = -666;
18 int a[x];
19 int aa[x][x];
20 int aaa[x][x][x];
21 int b[x - 4];
22 int c[(int) di];
23 int d[1 + x];
24 int e[1 ? x : -1];
25 int f[++x];
26 int g[(signed char) --x];
27 int h[(++x, --x, x)];
28 int i[v];
29 int j[bar ()];
31 return 0;
34 /* { dg-output "variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
35 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
36 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
37 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
38 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
39 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
40 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -5(\n|\r\n|\r)" } */
41 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -3(\n|\r\n|\r)" } */
42 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value 0(\n|\r\n|\r)" } */
43 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
44 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value 0(\n|\r\n|\r)" } */
45 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
46 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1(\n|\r\n|\r)" } */
47 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -666(\n|\r\n|\r)" } */
48 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -42(\n|\r\n|\r)" } */