gcc/testsuite/g++.dg/cpp0x/constexpr-throw.C
raw| 1 | // { dg-do compile { target c++11 } } |
| 2 | // Explicit { dg-require-effective-target exceptions_enabled } to avoid verify compiler messages FAILs for '-fno-exceptions'. |
| 3 | |
| 4 | constexpr int may_throw(bool decide) { |
| 5 | return decide ? 42 : throw -1; // { dg-error "throw" } |
| 6 | } |
| 7 | |
| 8 | constexpr int x = may_throw(false); // { dg-message "may_throw" } |
| 9 | constexpr int y = may_throw(true); |