1 // { dg-do compile { target c++17 } }
2
3 struct A { bool a, b; };
4 struct B { int a, b; };
5
6 void
foo()7 foo ()
8 {
9 auto [ a, b ] = A ();
10 for (; auto [ a, b ] = A (); ) // { dg-error "expected" }
11 ;
12 for (; false; auto [ a, b ] = A ()) // { dg-error "expected" }
13 ;
14 if (auto [ a, b ] = A ()) // { dg-error "expected" }
15 ;
16 if (auto [ a, b ] = A (); auto [ c, d ] = A ()) // { dg-error "expected" }
17 ;
18 if (int d = 5; auto [ a, b ] = A ()) // { dg-error "expected" }
19 ;
20 switch (auto [ a, b ] = B ()) // { dg-error "expected" }
21 {
22 case 2:
23 break;
24 }
25 switch (int d = 5; auto [ a, b ] = B ()) // { dg-error "expected" }
26 {
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 };
47