| 1 |
// PR c++/89513 |
| 2 |
// { dg-do compile { target c++14 } } |
| 3 |
// { dg-options "" } |
| 4 |
|
| 5 |
constexpr int foo () |
| 6 |
try { // { dg-warning "function-try-block body of 'constexpr' function only available with" "" { target c++17_down } } |
| 7 |
int a; // { dg-error "uninitialized variable 'a' in 'constexpr' function" "" { target c++17_down } } |
| 8 |
static double b = 1.0;// { dg-error "'b' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } } |
| 9 |
goto l; // { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } } |
| 10 |
l:; |
| 11 |
return 0; |
| 12 |
} catch (...) { |
| 13 |
long int c; // { dg-error "uninitialized variable 'c' in 'constexpr' function" "" { target c++17_down } } |
| 14 |
static float d = 2.0f;// { dg-error "'d' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } } |
| 15 |
goto l2; // { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } } |
| 16 |
l2:; |
| 17 |
return -1; |
| 18 |
} |
| 19 |
|
| 20 |
constexpr int bar () |
| 21 |
{ |
| 22 |
int a; // { dg-error "uninitialized variable 'a' in 'constexpr' function" "" { target c++17_down } } |
| 23 |
static long double b = 3.0;// { dg-error "'b' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } } |
| 24 |
goto l; // { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } } |
| 25 |
l:; |
| 26 |
try { // { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } } |
| 27 |
short c; // { dg-error "uninitialized variable 'c' in 'constexpr' function" "" { target c++17_down } } |
| 28 |
static float d; // { dg-error "'d' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } } |
| 29 |
// { dg-error "uninitialized variable 'd' in 'constexpr' function" "" { target c++17_down } .-1 } |
| 30 |
goto l2; // { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } } |
| 31 |
l2:; |
| 32 |
return 0; |
| 33 |
} catch (int) { |
| 34 |
char e; // { dg-error "uninitialized variable 'e' in 'constexpr' function" "" { target c++17_down } } |
| 35 |
static int f = 5; // { dg-error "'f' defined 'static' in 'constexpr' function only available with" "" { target c++20_down } } |
| 36 |
goto l3; // { dg-error "'goto' in 'constexpr' function only available with" "" { target c++20_down } } |
| 37 |
l3:; |
| 38 |
return 1; |
| 39 |
} |
| 40 |
} |