| 1 |
// PR c++/85952 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-Wunused-but-set-variable" } |
| 4 |
|
| 5 |
int |
| 6 |
foo () |
| 7 |
{ |
| 8 |
int a[2] = {1, 2}; // { dg-bogus "set but not used" } */ |
| 9 |
auto [x, y] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 10 |
return x + y; |
| 11 |
} |
| 12 |
|
| 13 |
struct S { int d, e; }; |
| 14 |
|
| 15 |
int |
| 16 |
bar () |
| 17 |
{ |
| 18 |
S a = {1, 2}; |
| 19 |
auto [x, y] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 20 |
return x + y; |
| 21 |
} |
| 22 |
|
| 23 |
int |
| 24 |
baz () |
| 25 |
{ |
| 26 |
S a = {1, 2}; |
| 27 |
auto & [x, y] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 28 |
return x + y; |
| 29 |
} |
| 30 |
|
| 31 |
int |
| 32 |
qux () |
| 33 |
{ |
| 34 |
int a[2] = {1, 2}; |
| 35 |
auto & [x, y] = a; // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 36 |
return x + y; |
| 37 |
} |