| 1 |
// PR c++/111069 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
extern int a[2]; |
| 6 |
struct Y { int b, c, d; }; |
| 7 |
|
| 8 |
inline int |
| 9 |
freddy () |
| 10 |
{ |
| 11 |
static auto [i, j] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 12 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 13 |
static auto [k, l] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 14 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 15 |
int ret = ++i + ++k; |
| 16 |
{ |
| 17 |
static auto [i, j] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 18 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 19 |
static auto [k, l] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 20 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 21 |
ret += ++i + ++k; |
| 22 |
} |
| 23 |
{ |
| 24 |
static auto [i, j] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 25 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 26 |
static auto [k, l] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 27 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 28 |
ret += ++i + ++k; |
| 29 |
} |
| 30 |
return ret; |
| 31 |
} |
| 32 |
|
| 33 |
namespace N |
| 34 |
{ |
| 35 |
namespace M |
| 36 |
{ |
| 37 |
template <int N> |
| 38 |
inline int |
| 39 |
corge () |
| 40 |
{ |
| 41 |
static auto [i, j] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 42 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 43 |
static auto && [u, v, w] = Y{}; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 44 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 45 |
int ret = ++i + ++u; |
| 46 |
{ |
| 47 |
static auto && [u, v, w] = Y{}; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 48 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 49 |
ret += ++v; |
| 50 |
} |
| 51 |
return ret; |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
int (*p) () = &freddy; |
| 57 |
int (*q) () = N::M::corge<3>; |
| 58 |
|
| 59 |
// { dg-final { scan-assembler "_ZZ6freddyvEDC1i1jE" } } |
| 60 |
// { dg-final { scan-assembler "_ZZ6freddyvEDC1i1jE_0" } } |
| 61 |
// { dg-final { scan-assembler "_ZZ6freddyvEDC1i1jE_1" } } |
| 62 |
// { dg-final { scan-assembler "_ZZ6freddyvEDC1k1lE" } } |
| 63 |
// { dg-final { scan-assembler "_ZZ6freddyvEDC1k1lE_0" } } |
| 64 |
// { dg-final { scan-assembler "_ZZ6freddyvEDC1k1lE_1" } } |
| 65 |
// { dg-final { scan-assembler "_ZZN1N1M5corgeILi3EEEivEDC1i1jE" } } |
| 66 |
// { dg-final { scan-assembler "_ZGVZ6freddyvEDC1i1jE" } } |
| 67 |
// { dg-final { scan-assembler "_ZGVZ6freddyvEDC1i1jE_0" } } |
| 68 |
// { dg-final { scan-assembler "_ZGVZ6freddyvEDC1i1jE_1" } } |
| 69 |
// { dg-final { scan-assembler "_ZGVZ6freddyvEDC1k1lE" } } |
| 70 |
// { dg-final { scan-assembler "_ZGVZ6freddyvEDC1k1lE_0" } } |
| 71 |
// { dg-final { scan-assembler "_ZGVZ6freddyvEDC1k1lE_1" } } |
| 72 |
// { dg-final { scan-assembler "_ZGVZN1N1M5corgeILi3EEEivEDC1i1jE" } } |
| 73 |
// { dg-final { scan-assembler "_ZGRZN1N1M5corgeILi3EEEivEDC1u1v1wE_" } } |
| 74 |
// { dg-final { scan-assembler "_ZGRZN1N1M5corgeILi3EEEivEDC1u1v1wE_0_" } } |