aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/nested-func-10.c
blob: ac6f76fbbe7c66a08ad00f04c3b3da7a9249b8a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* PR c/70093 */
/* { dg-do compile } */
/* { dg-options "" } */

void __attribute__((noinline, noclone))
foo (int n)
{
  struct S { int a[n]; };

  struct S __attribute__((noreturn))
  fn (void)
  {
    __builtin_abort ();
  }

  auto struct S __attribute__((noreturn))
  fn2 (void)
  {
    __builtin_abort ();
  }

  struct S x;
  __typeof__ (fn ()) *p = &x;
  switch (n)
    {
    case 1:
      fn ();
      break;
    case 2:
      fn2 ();
      break;
    case 3:
      x = fn ();
      if (x.a[0] != 42)
	__builtin_abort ();
      break;
    case 4:
      if (fn ().a[0] != 42)
	__builtin_abort ();
      break;
    case 5:
      if (p->a[0] != 42)
	__builtin_abort ();
      break;
    case 6:
      if (fn2 ().a[0] != 42)
	__builtin_abort ();
      break;
    }
}

int
main (void)
{
  foo (1);
}