1 // { dg-do compile { target c++11 } }
4 struct A { int a; struct { int b; }; };
5 struct B { int a; union { int c; long d; }; };
6 struct C { int a; private: int b; };
7 struct D { int a; private: static int b; };
8 struct E { protected: int a; };
10 struct G : public F { int b; };
12 struct I : public F, H {};
15 test (A &a, B &b, C &c, D &d, E &e, F &f, G &g, H &h, I &i)
17 auto [ j ] = a; // { dg-error "cannot decompose class type 'A' because it has an anonymous struct member" }
18 // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
19 auto [ k ] { b }; // { dg-error "cannot decompose class type 'B' because it has an anonymous union member" }
20 // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
21 auto [ l, l2 ] = c; // { dg-error "cannot decompose non-public member 'C::b' of 'C'" }
22 // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
23 auto [ m ] = d; // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } }
24 auto [ n ] { e }; // { dg-error "cannot decompose non-public member 'E::a' of 'E'" }
25 // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
26 auto [ o ] { f }; // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } }
27 auto & [ p ] { g }; // { dg-error "cannot decompose class type 'G': both it and its base class 'F' have non-static data members" }
28 // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }
29 auto [ q ] { h }; // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } }
30 auto [ r ] { i }; // { dg-error "cannot decompose class type 'I': its base classes 'F' and 'H' have non-static data members" }
31 // { dg-warning "structured bindings only available with -std=c..17 or -std=gnu..17" "" { target c++14_down } .-1 }