1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */
3 
4 typedef long int V;
5 int x = -1;
6 double di = -3.2;
7 V v = -6;
8 
9 static int __attribute__ ((noinline, noclone))
bar(void)10 bar (void)
11 {
12   return -4;
13 }
14 
15 static void __attribute__ ((noinline, noclone))
fn1(void)16 fn1 (void)
17 {
18   int a[x];
19 }
20 
21 static void __attribute__ ((noinline, noclone))
fn2(void)22 fn2 (void)
23 {
24   int a[x][x];
25 }
26 
27 static void __attribute__ ((noinline, noclone))
fn3(void)28 fn3 (void)
29 {
30   int a[x][x][x];
31 }
32 
33 static void __attribute__ ((noinline, noclone))
fn4(void)34 fn4 (void)
35 {
36   int b[x - 4];
37 }
38 
39 static void __attribute__ ((noinline, noclone))
fn5(void)40 fn5 (void)
41 {
42   int c[(int) di];
43 }
44 
45 static void __attribute__ ((noinline, noclone))
fn6(void)46 fn6 (void)
47 {
48   int d[1 + x];
49 }
50 
51 static void __attribute__ ((noinline, noclone))
fn7(void)52 fn7 (void)
53 {
54   int e[1 ? x : -1];
55 }
56 
57 static void __attribute__ ((noinline, noclone))
fn8(void)58 fn8 (void)
59 {
60   int f[++x];
61 }
62 
63 static void __attribute__ ((noinline, noclone))
fn9(void)64 fn9 (void)
65 {
66   int g[(signed char) --x];
67 }
68 
69 static void __attribute__ ((noinline, noclone))
fn10(void)70 fn10 (void)
71 {
72   int h[(++x, --x, x)];
73 }
74 
75 static void __attribute__ ((noinline, noclone))
fn11(void)76 fn11 (void)
77 {
78   int i[v];
79 }
80 
81 static void __attribute__ ((noinline, noclone))
fn12(void)82 fn12 (void)
83 {
84   int j[bar ()];
85 }
86 
87 int
main(void)88 main (void)
89 {
90   fn1 ();
91   fn2 ();
92   fn3 ();
93   fn4 ();
94   fn5 ();
95   fn6 ();
96   fn7 ();
97   fn8 ();
98   fn9 ();
99   fn10 ();
100   fn11 ();
101   fn12 ();
102   return 0;
103 }
104 
105 /* { dg-output "variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
106 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
107 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
108 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
109 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
110 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
111 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -5\[^\n\r]*(\n|\r\n|\r)" } */
112 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -3\[^\n\r]*(\n|\r\n|\r)" } */
113 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value 0\[^\n\r]*(\n|\r\n|\r)" } */
114 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
115 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value 0\[^\n\r]*(\n|\r\n|\r)" } */
116 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
117 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -1\[^\n\r]*(\n|\r\n|\r)" } */
118 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -6\[^\n\r]*(\n|\r\n|\r)" } */
119 /* { dg-output "\[^\n\r]*variable length array bound evaluates to non-positive value -4" } */
120