c: Support C2x empty initializer braces
[platform/upstream/gcc.git] / gcc / testsuite / gcc.dg / gnu2x-empty-init-2.c
1 /* Test C2X support for empty initializers: invalid use cases with GNU
2    extensions.  */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu2x" } */
5
6 void
7 f (int a)
8 {
9   /* Make sure a non-braced initializer for a VLA-in-struct is still not
10      allowed.  */
11   struct s { int x[a]; };
12   struct s b;
13   for (int i = 0; i < a; i++)
14     b.x[i] = 0;
15   struct s c = b; /* { dg-error "variable-sized object may not be initialized except with an empty initializer" } */
16 }