Debian Codegraph @

gcc/testsuite/gcc.dg/nested-func-10.c

raw
1 /* PR c/70093 */
2 /* { dg-do compile } */
3 /* { dg-options "" } */
4
5 void __attribute__((noinline, noclone))
6 foo (int n)
7 {
8 struct S { int a[n]; };
9
10 struct S __attribute__((noreturn))
11 fn (void)
12 {
13 __builtin_abort ();
14 }
15
16 auto struct S __attribute__((noreturn))
17 fn2 (void)
18 {
19 __builtin_abort ();
20 }
21
22 struct S x;
23 __typeof__ (fn ()) *p = &x;
24 switch (n)
25 {
26 case 1:
27 fn ();
28 break;
29 case 2:
30 fn2 ();
31 break;
32 case 3:
33 x = fn ();
34 if (x.a[0] != 42)
35 __builtin_abort ();
36 break;
37 case 4:
38 if (fn ().a[0] != 42)
39 __builtin_abort ();
40 break;
41 case 5:
42 if (p->a[0] != 42)
43 __builtin_abort ();
44 break;
45 case 6:
46 if (fn2 ().a[0] != 42)
47 __builtin_abort ();
48 break;
49 }
50 }
51
52 int
53 main (void)
54 {
55 foo (1);
56 }