| 1 |
// PR c++/89785 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
// Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'. |
| 4 |
|
| 5 |
constexpr int |
| 6 |
foo (int x) |
| 7 |
{ |
| 8 |
switch (x) |
| 9 |
{ |
| 10 |
case 0: |
| 11 |
break; |
| 12 |
case 2: |
| 13 |
break; |
| 14 |
} |
| 15 |
throw 42; // { dg-error "is not a constant expression" "" { target c++20_down } } |
| 16 |
return 0; |
| 17 |
} |
| 18 |
|
| 19 |
constexpr int |
| 20 |
bar (int x) |
| 21 |
{ |
| 22 |
do |
| 23 |
{ |
| 24 |
switch (x) |
| 25 |
{ |
| 26 |
case 0: |
| 27 |
throw 42; |
| 28 |
case 1: |
| 29 |
for (int i = 0; i < 10; i++) |
| 30 |
continue; |
| 31 |
break; |
| 32 |
} |
| 33 |
throw -42; // { dg-error "is not a constant expression" "" { target c++20_down } } |
| 34 |
} |
| 35 |
while (0); |
| 36 |
return x; |
| 37 |
} |