| 1 |
/* { dg-options "-Warray-bounds" } */ |
| 2 |
/* { dg-do compile } */ |
| 3 |
|
| 4 |
struct A |
| 5 |
{ |
| 6 |
int i; |
| 7 |
char p[1]; |
| 8 |
}; |
| 9 |
|
| 10 |
struct B |
| 11 |
{ |
| 12 |
struct A a; |
| 13 |
int i; |
| 14 |
}; |
| 15 |
|
| 16 |
struct C |
| 17 |
{ |
| 18 |
int i; |
| 19 |
struct A a; |
| 20 |
}; |
| 21 |
|
| 22 |
union D |
| 23 |
{ |
| 24 |
char p[1]; |
| 25 |
struct A a; |
| 26 |
struct B b; |
| 27 |
struct C c; |
| 28 |
}; |
| 29 |
|
| 30 |
struct E |
| 31 |
{ |
| 32 |
int i; |
| 33 |
union D d; |
| 34 |
}; |
| 35 |
|
| 36 |
struct F |
| 37 |
{ |
| 38 |
union D d; |
| 39 |
int i; |
| 40 |
}; |
| 41 |
|
| 42 |
union G |
| 43 |
{ |
| 44 |
int i; |
| 45 |
union D d; |
| 46 |
}; |
| 47 |
|
| 48 |
void |
| 49 |
f0 () |
| 50 |
{ |
| 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 */ |
| 70 |
} |