diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/gnu2x-empty-init-1.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/gnu2x-empty-init-1.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/gnu2x-empty-init-1.c b/gcc/testsuite/gcc.dg/gnu2x-empty-init-1.c new file mode 100644 index 0000000..e7dc9df --- /dev/null +++ b/gcc/testsuite/gcc.dg/gnu2x-empty-init-1.c @@ -0,0 +1,29 @@ +/* Test C2X support for empty initializers: valid use cases with GNU + extensions. */ +/* { dg-do run } */ +/* { dg-options "-std=gnu2x" } */ + +extern void exit (int); +extern void abort (void); + +void +f (int a) +{ + struct s { volatile int x[a]; }; + struct s b = {}; + for (int i = 0; i < a; i++) + if (b.x[i] != 0) + abort (); + /* Overwrite contents of b.x before second call to make it more likely stack + contents are nonzero if proper initialization did not occur. */ + for (int i = 0; i < a; i++) + b.x[i] = -1; +} + +int +main (void) +{ + f (100); + f (100); + exit (0); +} |