Debian Codegraph @

gcc/testsuite/g++.dg/cpp1z/decomp16.C

raw
1 // { dg-do compile { target c++17 } }
2
3 struct A { bool a, b; };
4 struct B { int a, b; };
5
6 void
7 foo ()
8 {
9 auto [ a, b ] = A ();
10 for (; auto [ a, b ] = A (); ) // { dg-error "structured bindings in conditions only available with" "" { target c++23_down } }
11 ; // { dg-error "could not convert '<structured bindings>' from 'A' to 'bool'" "" { target *-*-* } .-1 }
12 for (; false; auto [ a, b ] = A ()) // { dg-error "expected" }
13 ;
14 if (auto [ a, b ] = A ()) // { dg-error "structured bindings in conditions only available with" "" { target c++23_down } }
15 ; // { dg-error "could not convert '<structured bindings>' from 'A' to 'bool'" "" { target *-*-* } .-1 }
16 if (auto [ a, b ] = A (); auto [ c, d ] = A ()) // { dg-error "structured bindings in conditions only available with" "" { target c++23_down } }
17 ; // { dg-error "could not convert '<structured bindings>' from 'A' to 'bool'" "" { target *-*-* } .-1 }
18 if (int d = 5; auto [ a, b ] = A ()) // { dg-error "structured bindings in conditions only available with" "" { target c++23_down } }
19 ; // { dg-error "could not convert '<structured bindings>' from 'A' to 'bool'" "" { target *-*-* } .-1 }
20 switch (auto [ a, b ] = B ()) // { dg-error "structured bindings in conditions only available with" "" { target c++23_down } }
21 { // { dg-error "switch quantity not an integer" "" { target *-*-* } .-1 }
22 case 2:
23 break;
24 }
25 switch (int d = 5; auto [ a, b ] = B ()) // { dg-error "structured bindings in conditions only available with" "" { target c++23_down } }
26 { // { dg-error "switch quantity not an integer" "" { target *-*-* } .-1 }
27 case 2:
28 break;
29 }
30 A e = A ();
31 auto && [ c, d ] = e;
32 auto [ i, j ] = A (), [ k, l ] = A (); // { dg-error "expected" }
33 auto m = A (), [ n, o ] = A (); // { dg-error "expected" }
34 }
35
36 template <typename T>
37 auto [ a, b ] = A (); // { dg-error "expected" }
38
39 struct C
40 {
41 auto [ e, f ] = A (); // { dg-error "expected" }
42 mutable auto [ g, h ] = A (); // { dg-error "expected" }
43 virtual auto [ i, j ] = A (); // { dg-error "expected" }
44 explicit auto [ k, l ] = A (); // { dg-error "expected" }
45 friend auto [ m, n ] = A (); // { dg-error "expected" }
46 };