Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / gcc.dg / vla-stexp-6.c
blob3d96d38898bbd5b6ae0c4c2186e9867abd20e4bc
1 /* PR29970, PR91038 */
2 /* { dg-do run } */
3 /* { dg-options "-O2 -Wunused-variable" } */
5 int foo3b(void) // should not return 0
7 int n = 0;
8 return sizeof *({ n = 10; int x[n]; &x; });
11 int foo4(void) // should not ICE
13 return (*({
14 int n = 20;
15 char (*x)[n][n] = __builtin_malloc(n * n);
16 (*x)[12][1] = 1;
18 }))[12][1];
21 int foo5(void) // should return 1, returns 0
23 int n = 0;
24 return (*({
25 n = 20;
26 char (*x)[n][n] = __builtin_malloc(n * n);
27 (*x)[12][1] = 1;
28 (*x)[0][1] = 0;
30 }))[12][1];
33 int foo5c(void) // should return 400
35 int n = 0;
36 return sizeof(*({
37 n = 20;
38 char (*x)[n][n] = __builtin_malloc(n * n);
39 (*x)[12][1] = 1;
40 (*x)[0][1] = 0;
42 }));
45 int foo5b(void) // should return 1, returns 0
47 int n = 0; /* { dg-warning "unused variable" } */
48 return (*({
49 int n = 20;
50 char (*x)[n][n] = __builtin_malloc(n * n);
51 (*x)[12][1] = 1;
52 (*x)[0][1] = 0;
54 }))[12][1];
57 int foo5a(void) // should return 1, returns 0
59 return (*({
60 int n = 20;
61 char (*x)[n][n] = __builtin_malloc(n * n);
62 (*x)[12][1] = 1;
63 (*x)[0][1] = 0;
65 }))[12][1];
71 int main()
73 if (sizeof(int[10]) != foo3b())
74 __builtin_abort();
76 if (1 != foo4())
77 __builtin_abort();
79 if (400 != foo5c())
80 __builtin_abort();
82 if (1 != foo5a())
83 __builtin_abort();
85 if (1 != foo5b()) // -O0
86 __builtin_abort();
88 if (1 != foo5())
89 __builtin_abort();
91 return 0;