/cp
[official-gcc.git] / gcc / testsuite / g++.dg / cpp1y / vla4.C
blob74bf66a07d9dcd1fc733859112f377b834d143ff
1 // Test for range-based for with VLAs.
2 // { dg-do run { target c++11 } }
3 // { dg-options "-Wno-vla" }
5 #include <new>
7 void f(int i)
9   int ar[i];
10   int j = 0;
11   for (int& x : ar)
12     x = ++j;
13   [&ar]{
14     int k = 0;
15     for (int x : ar)
16       if (x != ++k)
17         __builtin_abort();
18   }();
21 int main()
23   f(42);                                // OK