aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/gnu23-empty-init-2.c
blob: f73d018c35a6636cf9d077362ce99aeff338f5cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/* Test C23 support for empty initializers: invalid use cases with GNU
   extensions.  */
/* { dg-do compile } */
/* { dg-options "-std=gnu23" } */

void
f (int a)
{
  /* Make sure a non-braced initializer for a VLA-in-struct is still not
     allowed.  */
  struct s { int x[a]; };
  struct s b;
  for (int i = 0; i < a; i++)
    b.x[i] = 0;
  struct s c = b; /* { dg-error "variable-sized object may not be initialized except with an empty initializer" } */
}