2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1z / decomp47.C
blobf0d202d696aca891b2d1085aea44592c5c7c4b4e
1 // PR c++/87122
2 // { dg-do run { target c++14 } }
3 // { dg-options "" }
5 extern "C" void abort ();
6 struct S { int a, b; };
7 int c;
9 template <int N>
10 void
11 foo ()
13   S x[4] = { { N, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } };
14   auto f = [](auto & y) {
15     for (auto & [ u, v ] : y)   // { dg-warning "structured bindings only available with" "" { target c++14_down } }
16       {
17         if ((u & 1) != 1 || v != u + 1 || u < N || u > 7 || (c & (1 << u))
18             || &u != &y[v / 2 - 1].a || &v != &y[v / 2 - 1].b)
19           abort ();
20         c |= 1 << u;
21       }
22   };
23   f (x);
26 int
27 main ()
29   foo<1> ();
30   if (c != 0xaa)
31     abort ();