111
|
1 // { dg-do compile { target c++11 } }
|
|
2 // { dg-options "" }
|
|
3
|
|
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; };
|
|
9 struct F { int a; };
|
|
10 struct G : public F { int b; };
|
|
11 struct H { int b; };
|
|
12 struct I : public F, H {};
|
|
13
|
|
14 void
|
|
15 test (A &a, B &b, C &c, D &d, E &e, F &f, G &g, H &h, I &i)
|
|
16 {
|
|
17 auto [ j ] = a; // { dg-error "cannot decompose class type 'A' because it has an anonymous struct member" }
|
145
|
18 // { dg-warning "structured bindings only available with '-std=c..17' or '-std=gnu..17'" "" { target c++14_down } .-1 }
|
111
|
19 auto [ k ] { b }; // { dg-error "cannot decompose class type 'B' because it has an anonymous union member" }
|
145
|
20 // { dg-warning "structured bindings only available with '-std=c..17' or '-std=gnu..17'" "" { target c++14_down } .-1 }
|
131
|
21 auto [ l, l2 ] = c; // { dg-error "cannot decompose inaccessible member 'C::b' of 'C'" }
|
145
|
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 } }
|
131
|
24 auto [ n ] { e }; // { dg-error "cannot decompose inaccessible member 'E::a' of 'E'" }
|
145
|
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 } }
|
111
|
27 auto & [ p ] { g }; // { dg-error "cannot decompose class type 'G': both it and its base class 'F' have non-static data members" }
|
145
|
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 } }
|
111
|
30 auto [ r ] { i }; // { dg-error "cannot decompose class type 'I': its base classes 'F' and 'H' have non-static data members" }
|
145
|
31 // { dg-warning "structured bindings only available with '-std=c..17' or '-std=gnu..17'" "" { target c++14_down } .-1 }
|
111
|
32 }
|