1 /* Test to verify that -Wzero-length-bounds and not -Warray-bounds is
2 issued for accesses to interior zero-length array members that are
3 within the bounds of the enclosing struct.
5 { dg-options "-O2 -Wall -fno-tree-vectorize" } */
10 struct B
{ int j
; struct A a
[0]; };
18 char cbuf1
[1 * sizeof (struct C
)];
19 char cbuf2
[2 * sizeof (struct C
)] = { };
21 void test_C_global_buf (void)
23 struct C
*p
= (struct C
*)&cbuf1
;
25 p
->b1
.a
[-1].i
= 0; // { dg-warning "\\\[-Warray-bounds" }
26 p
->b1
.a
[ 0].i
= 0; // { dg-warning "\\\[-Wzero-length-bounds" }
27 p
->b1
.a
[ 1].i
= 0; // { dg-warning "\\\[-Warray-bounds" }
30 p
->b2
.a
[ 0].i
= 0; // { dg-warning "\\\[-Warray-bounds" }
31 p
->b2
.a
[ 1].i
= 0; // { dg-warning "\\\[-Warray-bounds" }
34 p
= (struct C
*)&cbuf2
;
35 p
->b1
.a
[-1].i
= 0; // { dg-warning "\\\[-Warray-bounds" }
36 p
->b1
.a
[ 0].i
= 0; // { dg-warning "\\\[-Wzero-length-bounds" }
37 p
->b1
.a
[ 1].i
= 0; // { dg-warning "\\\[-Wzero-length-bounds" }
42 p
->b2
.a
[ 2].i
= 0; // { dg-warning "\\\[-Warray-bounds" }
43 p
->b2
.a
[ 3].i
= 0; // { dg-warning "\\\[-Warray-bounds" }