comparison gcc/testsuite/g++.dg/cpp2a/constexpr-try3.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 "" }
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 (...) {
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;
16 } catch (int) {
17 return false;
18 }
19 } catch (...) {
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
28 struct S {
29 constexpr S () try : m (1) // { dg-warning "function-try-block body of 'constexpr' constructor only available with" "" { target c++17_down } }
30 {
31 try { // { dg-warning "'try' in 'constexpr' function only available with" "" { target c++17_down } }
32 } catch (int) {
33 }
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-warning "function-try-block body of 'constexpr' constructor only available with" "" { target c++17_down } }
42 } catch (...) {
43 }
44 };