]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/testsuite/g++.dg/cpp1y/constexpr-79655.C
Consolidate constexpr array handling.
[thirdparty/gcc.git] / gcc / testsuite / g++.dg / cpp1y / constexpr-79655.C
1 // PR c++/79655
2 // { dg-do compile { target c++14 } }
3
4 constexpr int
5 foo (int x, int y)
6 {
7 int a[6] = { 1, 2, 3, 4, 5, 6 };
8 a[x] = 0; // { dg-error "is outside the bounds" }
9 return a[y]; // { dg-error "is outside the bounds" }
10 }
11
12 constexpr int b = foo (0, -1); // { dg-message "in .constexpr. expansion of " }
13 constexpr int c = foo (0, 6); // { dg-message "in .constexpr. expansion of " }
14 constexpr int d = foo (6, 0); // { dg-message "in .constexpr. expansion of " }
15 constexpr int e = foo (-1, 0); // { dg-message "in .constexpr. expansion of " }
16 static_assert (foo (5, 5) == 0, "");
17 static_assert (foo (4, 5) == 6, "");
18 static_assert (foo (5, 4) == 5, "");