1/* { dg-do run } */
2/* { dg-options "-fsanitize=vla-bound -Wall -Wno-unused-variable" } */
3
4typedef long int V;
5int x = -1;
6double di = -3.2;
7V v = -6;
8
9static int __attribute__ ((noinline, noclone))
10bar (void)
11{
12  return -4;
13}
14
15static void __attribute__ ((noinline, noclone))
16fn1 (void)
17{
18  int a[x];
19}
20
21static void __attribute__ ((noinline, noclone))
22fn2 (void)
23{
24  int a[x][x];
25}
26
27static void __attribute__ ((noinline, noclone))
28fn3 (void)
29{
30  int a[x][x][x];
31}
32
33static void __attribute__ ((noinline, noclone))
34fn4 (void)
35{
36  int b[x - 4];
37}
38
39static void __attribute__ ((noinline, noclone))
40fn5 (void)
41{
42  int c[(int) di];
43}
44
45static void __attribute__ ((noinline, noclone))
46fn6 (void)
47{
48  int d[1 + x];
49}
50
51static void __attribute__ ((noinline, noclone))
52fn7 (void)
53{
54  int e[1 ? x : -1];
55}
56
57static void __attribute__ ((noinline, noclone))
58fn8 (void)
59{
60  int f[++x];
61}
62
63static void __attribute__ ((noinline, noclone))
64fn9 (void)
65{
66  int g[(signed char) --x];
67}
68
69static void __attribute__ ((noinline, noclone))
70fn10 (void)
71{
72  int h[(++x, --x, x)];
73}
74
75static void __attribute__ ((noinline, noclone))
76fn11 (void)
77{
78  int i[v];
79}
80
81static void __attribute__ ((noinline, noclone))
82fn12 (void)
83{
84  int j[bar ()];
85}
86
87int
88main (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\[^\n\r]*" } */
120