| 1 |
// PR c++/89513 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-pedantic" } |
| 4 |
|
| 5 |
constexpr bool foo () |
| 6 |
try { // { dg-warning "function-try-block body of 'constexpr' function only available with" "" { target c++17_down } } |
| 7 |
return true; |
| 8 |
} catch (...) { // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } } |
| 9 |
return false; |
| 10 |
} // { dg-error "body of 'constexpr' function" "" { target c++11_only } } |
| 11 |
|
| 12 |
constexpr bool bar () |
| 13 |
try { // { dg-warning "function-try-block body of 'constexpr' function only available with" "" { target c++17_down } } |
| 14 |
try { // { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } } |
| 15 |
return true; // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } .-1 } |
| 16 |
} catch (int) { // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } } |
| 17 |
return false; |
| 18 |
} |
| 19 |
} catch (...) { // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } } |
| 20 |
return false; |
| 21 |
} // { dg-error "not a return-statement" "" { target c++11_only } } |
| 22 |
|
| 23 |
constexpr bool baz () |
| 24 |
{ |
| 25 |
try { return true; } catch (...) { return false; } // { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } } |
| 26 |
} // { dg-error "not a return-statement" "" { target c++11_only } } |
| 27 |
// { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } .-2 } |
| 28 |
|
| 29 |
struct S { |
| 30 |
constexpr S () try : m (1) // { dg-warning "function-try-block body of 'constexpr' constructor only available with" "" { target c++17_down } } |
| 31 |
{ |
| 32 |
try { // { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } } |
| 33 |
} catch (int) { // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } } |
| 34 |
} // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } .-2 } |
| 35 |
} catch (...) { // { dg-warning "'constexpr' constructor does not have empty body" "" { target c++11_only } } |
| 36 |
// { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } .-1 } |
| 37 |
} |
| 38 |
int m; |
| 39 |
}; |
| 40 |
|
| 41 |
struct T { |
| 42 |
constexpr T () |
| 43 |
try { // { dg-warning "function-try-block body of 'constexpr' constructor only available with" "" { target c++17_down } } |
| 44 |
} catch (...) { // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } } |
| 45 |
} |
| 46 |
}; |