c++: Implement for namespace statics CWG 2867 - Order of initialization for structure...
[official-gcc.git] / gcc / testsuite / gcc.dg / nested-vla-1.c
blobd1b3dc3c5f8c50772c4d870c3d0661ea905da989
1 /* { dg-do run } */
2 /* { dg-options "-std=gnu99" } */
3 /* { dg-require-effective-target trampolines } */
6 int main()
8 int n = 1;
10 struct foo { char x[++n]; } bar(void) { struct foo r; return r; }
12 if (2 != n)
13 __builtin_abort();
15 if (2 != sizeof(bar()))
16 __builtin_abort();
18 n = 1;
20 struct bar { char x[++n]; } (*bar2p)(void);
21 struct bar bar2(void) { struct bar r; return r; }
22 bar2p = &bar2;
24 if (2 != n)
25 __builtin_abort();
27 if (2 != sizeof((*bar2p)()))
28 __builtin_abort();
30 n = 1;
32 struct str { char x[++n]; } *bar3(void)
34 struct str* s = __builtin_malloc(sizeof(struct str));
35 if (!s)
36 __builtin_abort();
37 struct str t;
38 *s = t;
39 return s;
42 if (2 != n)
43 __builtin_abort();
45 struct str* p;
47 if (2 != sizeof(*(p = bar3())))
48 __builtin_abort();
50 __builtin_free(p);
52 n = 1;
54 struct { char x[++n]; } *bar4(void) { }
56 if (2 != n)
57 __builtin_abort();
58 #if 0
59 // UB
60 if (2 != sizeof(*bar4()))
61 __builtin_abort();
62 #endif