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