Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / vla-stexp-4.c
blob929768cd802734dcf0417c8368507103fe950395
1 /* PR29970, PR91038 */
2 /* { dg-do run } */
3 /* { dg-options "-O0 -Wunused-variable" } */
4 /* { dg-require-effective-target alloca } */
6 int foo3b(void) // should not return 0
8 int n = 0;
9 return sizeof *({ n = 10; int x[n]; &x; });
12 int foo4(void) // should not ICE
14 return (*({
15 int n = 20;
16 char (*x)[n][n] = __builtin_malloc(n * n);
17 (*x)[12][1] = 1;
19 }))[12][1];
22 int foo5(void) // should return 1, returns 0
24 int n = 0;
25 return (*({
26 n = 20;
27 char (*x)[n][n] = __builtin_malloc(n * n);
28 (*x)[12][1] = 1;
29 (*x)[0][1] = 0;
31 }))[12][1];
34 int foo5c(void) // should return 400
36 int n = 0;
37 return sizeof(*({
38 n = 20;
39 char (*x)[n][n] = __builtin_malloc(n * n);
40 (*x)[12][1] = 1;
41 (*x)[0][1] = 0;
43 }));
46 int foo5b(void) // should return 1, returns 0
48 int n = 0; /* { dg-warning "unused variable" } */
49 return (*({
50 int n = 20;
51 char (*x)[n][n] = __builtin_malloc(n * n);
52 (*x)[12][1] = 1;
53 (*x)[0][1] = 0;
55 }))[12][1];
58 int foo5a(void) // should return 1, returns 0
60 return (*({
61 int n = 20;
62 char (*x)[n][n] = __builtin_malloc(n * n);
63 (*x)[12][1] = 1;
64 (*x)[0][1] = 0;
66 }))[12][1];
72 int main()
74 if (sizeof(int[10]) != foo3b())
75 __builtin_abort();
77 if (1 != foo4())
78 __builtin_abort();
80 if (400 != foo5c())
81 __builtin_abort();
83 if (1 != foo5a())
84 __builtin_abort();
86 if (1 != foo5b()) // -O0
87 __builtin_abort();
89 if (1 != foo5())
90 __builtin_abort();
92 return 0;