| 1 |
/* PR120354: Test for -Wflex-array-member-not-at-end on union with |
| 2 |
flexible array members. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-Wflex-array-member-not-at-end" } */ |
| 5 |
|
| 6 |
struct P {}; |
| 7 |
union L {}; |
| 8 |
|
| 9 |
union X { |
| 10 |
int x[]; |
| 11 |
struct P y; |
| 12 |
}; |
| 13 |
|
| 14 |
struct T { |
| 15 |
union X x; /* { dg-warning "structure containing a flexible array member is not at the end of another structure" } */ |
| 16 |
int plug; |
| 17 |
}; |
| 18 |
|
| 19 |
struct Q { |
| 20 |
int len; |
| 21 |
int data[]; |
| 22 |
}; |
| 23 |
|
| 24 |
union Y { |
| 25 |
struct Q q; |
| 26 |
union L y; |
| 27 |
}; |
| 28 |
|
| 29 |
struct S { |
| 30 |
union Y y; /* { dg-warning "structure containing a flexible array member is not at the end of another structure" } */ |
| 31 |
int plug; |
| 32 |
}; |
| 33 |
|