Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp2a/constexpr-try2.C @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
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-error "'constexpr' constructor does not have empty body" "" { target c++11_only } } | |
36 } | |
37 int m; | |
38 }; | |
39 | |
40 struct T { | |
41 constexpr T () | |
42 try { // { dg-warning "function-try-block body of 'constexpr' constructor only available with" "" { target c++17_down } } | |
43 } catch (...) { // { dg-warning "compound-statement in 'constexpr' function" "" { target c++11_only } } | |
44 } | |
45 }; |