Debian Codegraph @

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

raw
1 /* PR c/70093 */
2 /* { dg-do run } */
3 /* { dg-options "" } */
4
5 void
6 foo (int n)
7 {
8 struct S { int a[n]; };
9
10 struct S
11 fn (void)
12 {
13 struct S s;
14 s.a[0] = 42;
15 return s;
16 }
17
18 auto struct S
19 fn2 (void)
20 {
21 return fn ();
22 }
23
24 struct S x;
25 fn ();
26 fn2 ();
27 x = fn ();
28
29 if (x.a[0] != 42)
30 __builtin_abort ();
31
32 if (fn ().a[0] != 42)
33 __builtin_abort ();
34
35 __typeof__ (fn ()) *p = &x;
36 if (p->a[0] != 42)
37 __builtin_abort ();
38
39 if (fn2 ().a[0] != 42)
40 __builtin_abort ();
41 }
42
43 int
44 main (void)
45 {
46 foo (1);
47 }