File tree Expand file tree Collapse file tree 3 files changed +9
-6
lines changed
gcc/testsuite/g++.dg/contracts/cpp26
libstdc++-v3/src/experimental Expand file tree Collapse file tree 3 files changed +9
-6
lines changed Original file line number Diff line number Diff line change 1
1
// test that the default contract violation handler can't throw
2
2
// { dg-do run }
3
- // { dg-options "-std=c++2a -fcontracts -fcontract-continuation-mode=on -fcontracts-nonattr " }
3
+ // { dg-options "-std=c++2a -fcontracts -fcontract-evaluation-semantic=observe -fcontracts-nonattr " }
4
4
5
- #include <experimental/contract>
6
5
#include <iostream>
7
6
#include <exception>
8
7
#include <cstdlib>
@@ -75,14 +74,17 @@ public:
75
74
76
75
typedef fail_buf < std ::streambuf > fail_streambuf ;
77
76
78
-
79
77
// Test that there is an active exception when we reach the terminate handler.
80
78
void my_term ()
81
79
{
82
80
try { throw ; }
83
- catch (...) { std ::exit (0 ); }
81
+ catch (const underflow_error & ) { std ::exit (0 ); }
82
+ catch (const overflow_error & ) { std ::exit (0 ); }
83
+ catch (const positioning_error & ) { std ::exit (0 ); }
84
84
}
85
85
86
+
87
+
86
88
void f (int x ) pre (x >= 0 )
87
89
{
88
90
try {
@@ -97,6 +99,7 @@ int main()
97
99
std ::set_terminate (my_term );
98
100
fail_streambuf buf ;
99
101
std ::cerr .rdbuf (& buf );
102
+ std ::cerr .exceptions (std ::ios ::badbit | std ::ios ::failbit | std ::ios ::eofbit );
100
103
try
101
104
{
102
105
f (-42 );
Original file line number Diff line number Diff line change 29
29
#endif
30
30
31
31
__attribute__ ((weak)) void
32
- handle_contract_violation (const std::experimental::contract_violation &violation) noexcept
32
+ handle_contract_violation (const std::experimental::contract_violation &violation)
33
33
{
34
34
#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE
35
35
bool level_default_p = violation.assertion_level () == " default" ;
Original file line number Diff line number Diff line change 30
30
#endif
31
31
32
32
__attribute__ ((weak)) void
33
- handle_contract_violation (const std::contracts::contract_violation &violation)
33
+ handle_contract_violation (const std::contracts::contract_violation &violation) noexcept
34
34
{
35
35
#if _GLIBCXX_HOSTED && _GLIBCXX_VERBOSE
36
36
You can’t perform that action at this time.
0 commit comments