| 1 |
// { dg-do run { target c++11 } } |
| 2 |
// { dg-options "" } |
| 3 |
|
| 4 |
struct A { int i; long long j; } a[64]; |
| 5 |
|
| 6 |
int |
| 7 |
main () |
| 8 |
{ |
| 9 |
int i = 0; |
| 10 |
for (auto &x : a) |
| 11 |
{ |
| 12 |
x.i = i; |
| 13 |
x.j = 2 * i++; |
| 14 |
} |
| 15 |
for (auto & [ x, y ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 16 |
{ |
| 17 |
x += 2; |
| 18 |
y += 3; |
| 19 |
} |
| 20 |
i = 0; |
| 21 |
for (const auto [ u, v ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 22 |
{ |
| 23 |
if (u != i + 2 || v != 2 * i++ + 3) |
| 24 |
__builtin_abort (); |
| 25 |
} |
| 26 |
i = 0; |
| 27 |
for (auto [ x, y ] : a) // { dg-warning "structured bindings only available with" "" { target c++14_down } } |
| 28 |
{ |
| 29 |
x += 4; |
| 30 |
y += 5; |
| 31 |
if (x != i + 6 || y != 2 * i++ + 8) |
| 32 |
__builtin_abort (); |
| 33 |
} |
| 34 |
i = 0; |
| 35 |
for (const auto x : a) |
| 36 |
{ |
| 37 |
if (x.i != i + 2 || x.j != 2 * i++ + 3) |
| 38 |
__builtin_abort (); |
| 39 |
} |
| 40 |
} |