| 1 |
/* testing the correct usage of flexible array members in unions |
| 2 |
and alone in structures. */ |
| 3 |
/* { dg-do compile } */ |
| 4 |
/* { dg-options "-pedantic-errors" } */ |
| 5 |
|
| 6 |
union with_fam_1 { |
| 7 |
int a; |
| 8 |
int b[]; /* { dg-error "flexible array member in union is a GCC extension" } */ |
| 9 |
}; |
| 10 |
|
| 11 |
union with_fam_2 { |
| 12 |
char a; |
| 13 |
int b[]; /* { dg-error "flexible array member in union is a GCC extension" } */ |
| 14 |
}; |
| 15 |
|
| 16 |
union with_fam_3 { |
| 17 |
char a[]; /* { dg-error "flexible array member in union is a GCC extension" } */ |
| 18 |
/* { dg-error "in an otherwise empty" "" { target c++ } .-1 } */ |
| 19 |
int b[]; /* { dg-error "flexible array member in union is a GCC extension" } */ |
| 20 |
}; |
| 21 |
|
| 22 |
struct only_fam { |
| 23 |
int b[]; |
| 24 |
/* { dg-error "in a struct with no named members" "" { target c } .-1 } */ |
| 25 |
/* { dg-error "in an otherwise empty" "" { target c++ } .-2 } */ |
| 26 |
/* { dg-error "forbids flexible array member" "" { target c++ } .-3 } */ |
| 27 |
}; |
| 28 |
|
| 29 |
struct only_fam_2 { |
| 30 |
unsigned int : 2; |
| 31 |
unsigned int : 3; |
| 32 |
int b[]; |
| 33 |
/* { dg-error "in a struct with no named members" "" { target c } .-1 } */ |
| 34 |
/* { dg-error "in an otherwise empty" "" { target c++ } .-2 } */ |
| 35 |
/* { dg-error "forbids flexible array member" "" { target c++ } .-3 } */ |
| 36 |
}; |