aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/gnu2x-empty-init-2.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/gnu2x-empty-init-2.c')
-rw-r--r--gcc/testsuite/gcc.dg/gnu2x-empty-init-2.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/gnu2x-empty-init-2.c b/gcc/testsuite/gcc.dg/gnu2x-empty-init-2.c
new file mode 100644
index 0000000..69ee4e3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gnu2x-empty-init-2.c
@@ -0,0 +1,16 @@
+/* Test C2X support for empty initializers: invalid use cases with GNU
+ extensions. */
+/* { dg-do compile } */
+/* { dg-options "-std=gnu2x" } */
+
+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" } */
+}