| 1 |
/* PR c/92326 - wrong bound in zero-length array diagnostics |
| 2 |
{ dg-do compile } |
| 3 |
{ dg-options "-O2 -Wall" } */ |
| 4 |
|
| 5 |
extern int a0[0]; |
| 6 |
extern int ax[]; |
| 7 |
|
| 8 |
void warn_global_array (void) |
| 9 |
{ |
| 10 |
a0[0] = 0; // { dg-warning "array bounds of 'int *\\\[0]'" } |
| 11 |
ax[-1] = 0; // { dg-warning "array bounds of 'int *\\\[]'" } |
| 12 |
} |
| 13 |
|
| 14 |
|
| 15 |
struct S0 { int n, a0[0]; } s0; |
| 16 |
struct Sx { int n, ax[]; } sx = { 0 }; |
| 17 |
|
| 18 |
void warn_member_array (void) |
| 19 |
{ |
| 20 |
s0.a0[0] = 0; // { dg-warning "array bounds of 'int *\\\[0]'" } |
| 21 |
sx.ax[0] = 0; // { dg-warning "array bounds of 'int *\\\[]'" } |
| 22 |
} |