diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/countof-zero.c')
-rw-r--r-- | gcc/testsuite/gcc.dg/countof-zero.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/countof-zero.c b/gcc/testsuite/gcc.dg/countof-zero.c new file mode 100644 index 0000000..27b5bdd --- /dev/null +++ b/gcc/testsuite/gcc.dg/countof-zero.c @@ -0,0 +1,31 @@ +/* { dg-do run } */ +/* { dg-options "-std=gnu2y" } */ + +#define assert(e) ((e) ? (void) 0 : __builtin_abort ()) + +void +vla (void) +{ + unsigned n; + + n = 0; + int z[n]; + assert (_Countof (z) == 0); +} + +void +matrix_vla (void) +{ + int i; + + i = 0; + assert (_Countof (int [i++][4]) == 0); + assert (i == 0 + 1); +} + +int +main (void) +{ + vla (); + matrix_vla (); +} |