2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1z / decomp7.C
blob545c5cf1060afed5e61b947864acad4a6907b2f9
1 // { dg-do run { target c++11 } }
2 // { dg-options "" }
4 int a[2] = { 1, 2 };
5 int b[2] = { 4, 5 };
6 struct S { int a; signed char b; float c; } sa = { 6, 7, 8.0f };
7 S sb = { 9, 10, 11.0f };
9 template <typename T, typename U>
10 void
11 foo (T &x, U &y)
13   auto & [ c, d ] = a;          // { dg-warning "structured bindings only available with" "" { target c++14_down } }
14   auto [ e, f ] = a;            // { dg-warning "structured bindings only available with" "" { target c++14_down } }
15   auto [ g, h, i ] = sa;        // { dg-warning "structured bindings only available with" "" { target c++14_down } }
16   auto & [ j, k, l ] = sa;      // { dg-warning "structured bindings only available with" "" { target c++14_down } }
17   auto & [ m, n ] = x;          // { dg-warning "structured bindings only available with" "" { target c++14_down } }
18   auto [ o, p ] = x;            // { dg-warning "structured bindings only available with" "" { target c++14_down } }
19   auto [ q, r, s ] = y;         // { dg-warning "structured bindings only available with" "" { target c++14_down } }
20   auto & [ t, u, v ] = y;       // { dg-warning "structured bindings only available with" "" { target c++14_down } }
21   c += 1;
22   e += 2;
23   g += 3;
24   j += 4;
25   m += 5;
26   o += 6;
27   q += 7;
28   t += 8;
29   if (c != 2 || &c != &a[0]
30       || d != 2 || &d != &a[1]
31       || e != 3 || &e == &a[0]
32       || f != 2 || &f == &a[1]
33       || g != 9 || &g == &sa.a
34       || h != 7 || &h == &sa.b
35       || i != 8.0f || &i == &sa.c
36       || j != 10 || &j != &sa.a
37       || k != 7 || &k != &sa.b
38       || l != 8.0f || &l != &sa.c
39       || m != 9 || &m != &b[0]
40       || n != 5 || &n != &b[1]
41       || o != 10 || &o == &b[0]
42       || p != 5 || &p == &b[1]
43       || q != 16 || &q == &sb.a
44       || r != 10 || &r == &sb.b
45       || s != 11.0f || &s == &sb.c
46       || t != 17 || &t != &sb.a
47       || u != 10 || &u != &sb.b
48       || v != 11.0f || &v != &sb.c
49       || a[0] != 2 || a[1] != 2
50       || sa.a != 10 || sa.b != 7 || sa.c != 8.0f
51       || b[0] != 9 || b[1] != 5
52       || sb.a != 17 || sb.b != 10 || sb.c != 11.0f)
53     __builtin_abort ();
56 int
57 main ()
59   foo (b, sb);