| 1 |
// { dg-do compile { target c++11 } } |
| 2 |
// { dg-options "" } |
| 3 |
|
| 4 |
struct A { int i; long j; int k : 2; char l; } a; |
| 5 |
int c[2]; |
| 6 |
struct B { template<int I> int &get () { return c[I]; } } b; |
| 7 |
namespace std { |
| 8 |
template<typename T> struct tuple_size; |
| 9 |
template<int, typename> struct tuple_element; |
| 10 |
} |
| 11 |
template<> struct std::tuple_size<B> { static constexpr int value = 2; }; |
| 12 |
template<int I> struct std::tuple_element<I,B> { typedef int type; }; |
| 13 |
|
| 14 |
auto [ aa, bb, cc, dd ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 15 |
// { dg-final { scan-assembler "_ZDC2aa2bb2cc2ddE" } } |
| 16 |
const auto & [ e, f, g, h ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 17 |
// { dg-final { scan-assembler "_ZDC1e1f1g1hE" } } |
| 18 |
auto [ ee, ff ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 19 |
// { dg-final { scan-assembler "_ZDC2ee2ffE" } } |
| 20 |
auto & [ gg, hh ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 21 |
// { dg-final { scan-assembler "_ZDC2gg2hhE" } } |
| 22 |
namespace N |
| 23 |
{ |
| 24 |
namespace M |
| 25 |
{ |
| 26 |
auto [ i, j, k, l ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 27 |
// { dg-final { scan-assembler "_ZN1N1MDC1i1j1k1lEE" } } |
| 28 |
auto & [ m, n, o, ppp ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 29 |
// { dg-final { scan-assembler "_ZN1N1MDC1m1n1o3pppEE" } } |
| 30 |
auto [ ii, jj ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 31 |
// { dg-final { scan-assembler "_ZN1N1MDC2ii2jjEE" } } |
| 32 |
// { dg-final { scan-assembler "_ZN1N1M2iiE" } } |
| 33 |
// { dg-final { scan-assembler "_ZN1N1M2jjE" } } |
| 34 |
auto & [ mm, nn ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 35 |
// { dg-final { scan-assembler "_ZN1N1MDC2mm2nnEE" } } |
| 36 |
// { dg-final { scan-assembler "_ZN1N1M2mmE" } } |
| 37 |
// { dg-final { scan-assembler "_ZN1N1M2nnE" } } |
| 38 |
} |
| 39 |
} |
| 40 |
namespace std |
| 41 |
{ |
| 42 |
auto [ i2, j2, k2, l2 ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 43 |
// { dg-final { scan-assembler "_ZStDC2i22j22k22l2E" } } |
| 44 |
auto [ vv, ww ] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 45 |
// { dg-final { scan-assembler "_ZStDC2vv2wwE" } } |
| 46 |
// { dg-final { scan-assembler "_ZSt2vv" } } |
| 47 |
// { dg-final { scan-assembler "_ZSt2ww" } } |
| 48 |
} |
| 49 |
namespace |
| 50 |
{ |
| 51 |
auto [ v, w, x, y ] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 52 |
} |