Merge aosp-toolchain/gcc/gcc-4_9 changes.
[official-gcc.git] / gcc-4_9 / gcc / testsuite / c-c++-common / pr41935.c
blob3279e75593d45b1d1c5656e9a5770881ba33b0a4
1 /* { dg-options "-Warray-bounds" } */
2 /* { dg-do compile } */
4 struct A
6 int i;
7 char p[1];
8 };
10 struct B
12 struct A a;
13 int i;
16 struct C
18 int i;
19 struct A a;
22 union D
24 char p[1];
25 struct A a;
26 struct B b;
27 struct C c;
30 struct E
32 int i;
33 union D d;
36 struct F
38 union D d;
39 int i;
42 union G
44 int i;
45 union D d;
48 void
49 f0 ()
51 __builtin_offsetof (struct A, p[4]); /* OK */
52 __builtin_offsetof (struct B, a.p[4]); /* { dg-warning "greater than size" } */
53 __builtin_offsetof (struct C, a.p[4]); /* OK */
54 __builtin_offsetof (union D, p[4]); /* OK */
55 __builtin_offsetof (union D, a.p[4]); /* OK */
56 __builtin_offsetof (union D, b.a.p[4]); /* { dg-warning "greater than size" } */
57 __builtin_offsetof (union D, c.a.p[4]); /* OK */
58 __builtin_offsetof (struct E, d.p[4]); /* OK */
59 __builtin_offsetof (struct E, d.a.p[4]); /* OK */
60 __builtin_offsetof (struct E, d.b.a.p[4]); /* { dg-warning "greater than size" } */
61 __builtin_offsetof (struct E, d.c.a.p[4]); /* OK */
62 __builtin_offsetof (struct F, d.p[4]); /* { dg-warning "greater than size" } */
63 __builtin_offsetof (struct F, d.a.p[4]); /* { dg-warning "greater than size" } */
64 __builtin_offsetof (struct F, d.b.a.p[4]); /* { dg-warning "greater than size" } */
65 __builtin_offsetof (struct F, d.c.a.p[4]); /* { dg-warning "greater than size" } */
66 __builtin_offsetof (union G, d.p[4]); /* OK */
67 __builtin_offsetof (union G, d.a.p[4]); /* OK */
68 __builtin_offsetof (union G, d.b.a.p[4]); /* { dg-warning "greater than size" } */
69 __builtin_offsetof (union G, d.c.a.p[4]); /* OK */