1 /* Verify warnings fpr accesses to trailing one-element array members
2 of a struct that's a member of either a struct or a union. Both
3 are obviously undefined but GCC relies on these hacks so the test
4 verifies that -Warray-bounds doesn't trigger for it.
5 { do-do compile }
6 { dg-options "-O2 -Wall" } */
7
8
9 typedef union tree_node *tree;
10
11 struct tree_exp { int i; tree operands[1]; };
12
13 union tree_node
14 {
15 struct tree_exp exp;
16 };
17
18 tree test_nowarn (tree t)
19 {
20 return t->exp.operands[3]; // { dg-bogus "\\\[-Warray-bounds" }
21 }
22
23
24 typedef struct shrub_node *shrub;
25
26 struct shrub_exp { int i; shrub operands[1]; };
27
28 struct shrub_node
29 {
30 struct shrub_exp exp;
31 };
32
33 shrub test_warn (shrub s)
34 {
35 return s->exp.operands[3]; // { dg-warning "\\\[-Warray-bounds" "pr96346" { xfail *-*-* } }
36 }