| 1 |
// PR c++/111069 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
struct [[gnu::abi_tag ("foobar")]] S { int i; }; |
| 6 |
extern S a[2]; |
| 7 |
struct [[gnu::abi_tag ("qux")]] T { int i; S j; int k; }; |
| 8 |
extern T b[2]; |
| 9 |
|
| 10 |
namespace N { |
| 11 |
auto [i, j] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 12 |
auto [k, l] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 13 |
} |
| 14 |
|
| 15 |
inline int |
| 16 |
foo () |
| 17 |
{ |
| 18 |
static auto [m, n] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 19 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 20 |
static auto [o, p] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 21 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 22 |
int ret = ++N::i.i + ++N::k.i; |
| 23 |
{ |
| 24 |
static auto [m, n] = 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 |
|
| 27 |
ret += ++n.i; |
| 28 |
} |
| 29 |
{ |
| 30 |
static auto [m, n] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 31 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 32 |
|
| 33 |
ret += ++n.i; |
| 34 |
} |
| 35 |
ret += ++m.i + ++o.i; |
| 36 |
return ret; |
| 37 |
} |
| 38 |
|
| 39 |
template <typename T> |
| 40 |
inline int |
| 41 |
bar () |
| 42 |
{ |
| 43 |
static auto [m, n] = a; // { 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 |
static auto [o, p] = b; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 46 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 47 |
int ret = 0; |
| 48 |
{ |
| 49 |
static auto [m, n] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 50 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 51 |
ret += ++n.i; |
| 52 |
} |
| 53 |
{ |
| 54 |
static auto [m, n] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 55 |
// { dg-warning "structured binding declaration can be 'static' only in" "" { target c++17_down } .-1 } |
| 56 |
ret += ++n.i; |
| 57 |
} |
| 58 |
ret += ++m.i + ++o.i; |
| 59 |
return ret; |
| 60 |
} |
| 61 |
|
| 62 |
int (*p) () = &foo; |
| 63 |
int (*q) () = &bar<T>; |
| 64 |
|
| 65 |
// { dg-final { scan-assembler "_ZZ3foovEDC1m1nEB6foobar" } } |
| 66 |
// { dg-final { scan-assembler "_ZZ3foovEDC1m1nEB6foobar_0" } } |
| 67 |
// { dg-final { scan-assembler "_ZZ3foovEDC1m1nEB6foobar_1" } } |
| 68 |
// { dg-final { scan-assembler "_ZZ3foovEDC1o1pEB3qux" } } |
| 69 |
// { dg-final { scan-assembler "_ZZ3barI1TB3quxEivEDC1m1nEB6foobar" } } |
| 70 |
// { dg-final { scan-assembler "_ZZ3barI1TB3quxEivEDC1m1nEB6foobar_0" } } |
| 71 |
// { dg-final { scan-assembler "_ZZ3barI1TB3quxEivEDC1m1nEB6foobar_1" } } |
| 72 |
// { dg-final { scan-assembler "_ZZ3barI1TB3quxEivEDC1o1pEB3qux" } } |
| 73 |
// { dg-final { scan-assembler "_ZN1NDC1i1jEB6foobarE" } } |
| 74 |
// { dg-final { scan-assembler "_ZN1NDC1k1lEB3quxE" } } |
| 75 |
// { dg-final { scan-assembler "_ZGVZ3foovEDC1m1nEB6foobar" } } |
| 76 |
// { dg-final { scan-assembler "_ZGVZ3foovEDC1m1nEB6foobar_0" } } |
| 77 |
// { dg-final { scan-assembler "_ZGVZ3foovEDC1m1nEB6foobar_1" } } |
| 78 |
// { dg-final { scan-assembler "_ZGVZ3foovEDC1o1pEB3qux" } } |
| 79 |
// { dg-final { scan-assembler "_ZGVZ3barI1TB3quxEivEDC1m1nEB6foobar" } } |
| 80 |
// { dg-final { scan-assembler "_ZGVZ3barI1TB3quxEivEDC1m1nEB6foobar_0" } } |
| 81 |
// { dg-final { scan-assembler "_ZGVZ3barI1TB3quxEivEDC1m1nEB6foobar_1" } } |
| 82 |
// { dg-final { scan-assembler "_ZGVZ3barI1TB3quxEivEDC1o1pEB3qux" } } |