gcc/testsuite/gcc.dg/gnu23-empty-init-2.c
raw| 1 | /* Test C23 support for empty initializers: invalid use cases with GNU |
| 2 | extensions. */ |
| 3 | /* { dg-do compile } */ |
| 4 | /* { dg-options "-std=gnu23" } */ |
| 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 | } |