PR middle-end/77357 - strlen of constant strings not folded
[official-gcc.git] / gcc / testsuite / gcc.dg / nested-func-10.c
blobe017fba871e3159f841564e7e70b0f0ee6e15561
1 /* PR c/70093 */
2 /* { dg-do compile } */
3 /* { dg-options "" } */
4 /* { dg-require-effective-target alloca } */
6 void __attribute__((noinline, noclone))
7 foo (int n)
9 struct S { int a[n]; };
11 struct S __attribute__((noreturn))
12 fn (void)
14 __builtin_abort ();
17 auto struct S __attribute__((noreturn))
18 fn2 (void)
20 __builtin_abort ();
23 struct S x;
24 __typeof__ (fn ()) *p = &x;
25 switch (n)
27 case 1:
28 fn ();
29 break;
30 case 2:
31 fn2 ();
32 break;
33 case 3:
34 x = fn ();
35 if (x.a[0] != 42)
36 __builtin_abort ();
37 break;
38 case 4:
39 if (fn ().a[0] != 42)
40 __builtin_abort ();
41 break;
42 case 5:
43 if (p->a[0] != 42)
44 __builtin_abort ();
45 break;
46 case 6:
47 if (fn2 ().a[0] != 42)
48 __builtin_abort ();
49 break;
53 int
54 main (void)
56 foo (1);