PR c++/85553
[official-gcc.git] / gcc / testsuite / g++.dg / ext / constexpr-vla1.C
blobaff1d21a4b7badbe288fd42576e93b13946e472b
1 // PR c++/69496
2 // { dg-do compile { target c++14 } }
4 constexpr int
5 fn_ok (int n)
7     __extension__ int a[n] = { };
8     int z = 0;
10     for (unsigned i = 0; i < sizeof (a) / sizeof (int); ++i)
11       z += a[i];
13     return z;
17 constexpr int
18 fn_not_ok (int n)
20     __extension__ int a[n] = { };
21     int z = 0;
23     for (unsigned i = 0; i < sizeof (a); ++i)
24       z += a[i];
26     return z;
29 constexpr int n1 = fn_ok (3);
30 constexpr int n2 = fn_not_ok (3); // { dg-error "array subscript|in .constexpr. expansion of " }