libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / c23-empty-init-2.c
blob84a9e65f895049aa7d416ff819e961c90ea2372e
1 /* Test C23 support for empty initializers: invalid use cases. */
2 /* { dg-do compile } */
3 /* { dg-options "-std=c23 -pedantic-errors" } */
5 /* Empty initialization is invalid for arrays of unknown size. This is
6 diagnosed via the diagnostic for zero-size arrays. */
7 int x[] = {}; /* { dg-error "zero or negative size array" } */
9 void
10 f (int a)
12 int x1[] = {}; /* { dg-error "zero or negative size array" } */
13 int x2[][a] = {}; /* { dg-error "zero or negative size array" } */
14 /* Nonempty VLA initializers are still invalid. */
15 int x3[a] = { 0 }; /* { dg-error "variable-sized object may not be initialized except with an empty initializer" } */
16 /* Variable-size compound literals are still invalid. */
17 (void) (int [a]) {}; /* { dg-error "compound literal has variable size" } */