| 1 |
// PR c++/117516 |
| 2 |
// { dg-do compile } |
| 3 |
// { dg-options "-Wpedantic -Wno-error=pedantic" } |
| 4 |
|
| 5 |
struct A { int a; char b[]; int c; }; // { dg-warning "forbids flexible array member" } |
| 6 |
// { dg-error "flexible array member 'A::b' not at end of 'struct A'" "" { target *-*-* } .-1 } |
| 7 |
struct B { struct A d; struct A e[]; struct A f; }; // { dg-warning "forbids flexible array member" } |
| 8 |
// { dg-error "flexible array member 'B::e' not at end of 'struct B'" "" { target *-*-* } .-1 } |
| 9 |
struct C { struct B g; struct B h[]; struct B i; }; // { dg-warning "forbids flexible array member" } |
| 10 |
// { dg-error "flexible array member 'C::h' not at end of 'struct C'" "" { target *-*-* } .-1 } |
| 11 |
struct D { struct C j; }; |
| 12 |
D k; |
| 13 |
struct E { int l; struct { int m; int n[]; int o; } p; int q; }; // { dg-warning "forbids flexible array member" } |
| 14 |
// { dg-error "flexible array member 'E::<unnamed struct>::n' not at end of 'struct E'" "" { target *-*-* } .-1 } |
| 15 |
struct F {}; |
| 16 |
struct G { int r[]; }; // { dg-warning "forbids flexible array member" } |
| 17 |
// { dg-warning "flexible array member 'G::r' in an otherwise empty 'struct G' is a GCC extension" "" { target *-*-* } .-1 } |
| 18 |
struct H { int s; int t[]; }; // { dg-warning "forbids flexible array member" } |
| 19 |
// { dg-error "flexible array member 'H::t' not at end of 'struct K'" "" { target *-*-* } .-1 } |
| 20 |
// { dg-message "array member 'int H::t \\\[\\\]' declared here" "" { target *-*-* } .-2 } |
| 21 |
#if __cplusplus >= 202002L |
| 22 |
struct I { [[no_unique_address]] F u; [[no_unique_address]] F v; int w[]; }; // { dg-warning "forbids flexible array member" "" { target c++20 } } |
| 23 |
#endif |
| 24 |
struct J { int x; struct H y; }; // { dg-warning "invalid use of 'struct H' with a flexible array member in 'struct J'" } |
| 25 |
struct K { int z; struct H aa; int ab; }; // { dg-message "next member 'int K::ab' declared here" } |
| 26 |
// { dg-message "in the definition of 'struct K'" "" { target *-*-* } .-1 } |