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