111
|
1 // { dg-do compile { target c++14 } }
|
|
2
|
|
3 constexpr void f1() {
|
|
4 if (false)
|
|
5 throw;
|
|
6 }
|
|
7
|
|
8 constexpr void f2() {
|
|
9 if (true)
|
|
10 throw; // { dg-error "not a constant expression" }
|
|
11 }
|
|
12
|
|
13 constexpr void f3() {
|
|
14 if (false)
|
|
15 ;
|
|
16 else
|
|
17 throw; // { dg-error "not a constant expression" }
|
|
18 }
|
|
19
|
|
20 constexpr void f4() {
|
|
21 throw; // { dg-error "not a constant expression" }
|
|
22 }
|
|
23
|
|
24 constexpr int fun(int n) {
|
|
25 switch (n) {
|
|
26 case 0:
|
|
27 return 1;
|
|
28 default:
|
|
29 throw; // { dg-error "not a constant expression" }
|
|
30 }
|
|
31 }
|
|
32
|
|
33 static_assert(fun(0), "");
|
131
|
34 static_assert(fun(1), ""); // { dg-error "non-constant|in .constexpr. expansion of" }
|