comparison gcc/testsuite/gcc.dg/nested-func-9.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
comparison
equal deleted inserted replaced
68:561a7518be6b 111:04ced10e8804
1 /* PR c/70093 */
2 /* { dg-do run } */
3 /* { dg-options "" } */
4 /* { dg-require-effective-target alloca } */
5
6 void
7 foo (int n)
8 {
9 struct S { int a[n]; };
10
11 struct S
12 fn (void)
13 {
14 struct S s;
15 s.a[0] = 42;
16 return s;
17 }
18
19 auto struct S
20 fn2 (void)
21 {
22 return fn ();
23 }
24
25 struct S x;
26 fn ();
27 fn2 ();
28 x = fn ();
29
30 if (x.a[0] != 42)
31 __builtin_abort ();
32
33 if (fn ().a[0] != 42)
34 __builtin_abort ();
35
36 __typeof__ (fn ()) *p = &x;
37 if (p->a[0] != 42)
38 __builtin_abort ();
39
40 if (fn2 ().a[0] != 42)
41 __builtin_abort ();
42 }
43
44 int
45 main (void)
46 {
47 foo (1);
48 }