gcc/testsuite/g++.dg/cpp1y/constexpr-89785-1.C
raw| 1 | // PR c++/89785 |
| 2 | // { dg-do compile { target c++14 } } |
| 3 | |
| 4 | constexpr int |
| 5 | foo (int x) |
| 6 | { |
| 7 | switch (x) |
| 8 | { |
| 9 | case 0: |
| 10 | throw -42; |
| 11 | case 2: |
| 12 | return 42; |
| 13 | } |
| 14 | throw 42; |
| 15 | } |
| 16 | |
| 17 | constexpr int |
| 18 | bar (int x) |
| 19 | { |
| 20 | do |
| 21 | { |
| 22 | switch (x) |
| 23 | { |
| 24 | case 0: |
| 25 | throw 42; |
| 26 | case 1: |
| 27 | continue; |
| 28 | } |
| 29 | throw -42; |
| 30 | } |
| 31 | while (0); |
| 32 | return x; |
| 33 | } |
| 34 | |
| 35 | static_assert (foo (2) == 42, ""); |
| 36 | static_assert (bar (1) == 1, ""); |