2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / nested-func-9.c
blob633ab6993d0ac63014e54afea16882a94e0cac88
1 /* PR c/70093 */
2 /* { dg-do run } */
3 /* { dg-options "" } */
4 /* { dg-require-effective-target alloca } */
6 void
7 foo (int n)
9 struct S { int a[n]; };
11 struct S
12 fn (void)
14 struct S s;
15 s.a[0] = 42;
16 return s;
19 auto struct S
20 fn2 (void)
22 return fn ();
25 struct S x;
26 fn ();
27 fn2 ();
28 x = fn ();
30 if (x.a[0] != 42)
31 __builtin_abort ();
33 if (fn ().a[0] != 42)
34 __builtin_abort ();
36 __typeof__ (fn ()) *p = &x;
37 if (p->a[0] != 42)
38 __builtin_abort ();
40 if (fn2 ().a[0] != 42)
41 __builtin_abort ();
44 int
45 main (void)
47 foo (1);