| 1 |
// PR c++/120039 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
struct S { |
| 6 |
int a; long long b; short c; |
| 7 |
explicit operator bool () const noexcept { return true; } |
| 8 |
}; |
| 9 |
|
| 10 |
template <int N> |
| 11 |
void |
| 12 |
foo () |
| 13 |
{ |
| 14 |
S s = S { 1, 2, 3 }; |
| 15 |
if (auto [sx, sy, sz] : s) // { dg-warning "structured bindings in conditions only available with" "" { target c++23_down } } |
| 16 |
; // { dg-error "expected initializer before ':' token" "" { target *-*-* } .-1 } |
| 17 |
} // { dg-error "expected '\\\)' before ':' token" "" { target *-*-* } .-2 } |
| 18 |
|
| 19 |
int |
| 20 |
main () |
| 21 |
{ |
| 22 |
foo <0> (); |
| 23 |
} |