gcc/testsuite/gcc.dg/Wzero-length-array-bounds-3.c
raw| 1 | /* PR tree-optimization/109215 */ |
| 2 | /* { dg-do compile } */ |
| 3 | /* { dg-options "-O2 -Wall" } */ |
| 4 | |
| 5 | struct S {}; |
| 6 | struct T { struct S s[3]; struct S t; }; |
| 7 | void foo (struct S *); |
| 8 | |
| 9 | void |
| 10 | bar (struct T *t) |
| 11 | { |
| 12 | foo (&t->s[2]); /* { dg-bogus "array subscript 2 is outside the bounds of an interior zero-length array" } */ |
| 13 | } |
| 14 | |
| 15 | void |
| 16 | baz (struct T *t) |
| 17 | { |
| 18 | foo (&t->s[3]); /* { dg-error "" "" { xfail *-*-* } } */ |
| 19 | } |