File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
gcc/testsuite/g++.dg/contracts/cpp26/definition-checks Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Check that contract asserts are checkef when the definition side contracts
2
+ // are turned off
3
+ // { dg-do run }
4
+ // { dg-options "-std=c++2a -fcontracts -fcontracts-nonattr -fcontracts-nonattr-definition-check=off -fcontract-evaluation-semantic=observe" }
5
+
6
+ #include <cstdlib>
7
+
8
+ bool termintating_check (){
9
+ std ::exit (-1 );
10
+ return true;
11
+ }
12
+ // pre and post check would cause termination
13
+ void foo (int i ) noexcept pre (termintating_check ()) post (termintating_check ()) {
14
+
15
+ contract_assert (i > 4 );
16
+
17
+ }
18
+
19
+ int main (int , char * * )
20
+ {
21
+
22
+ foo (1 );
23
+ return 0 ;
24
+ }
25
+ // { dg-output "contract violation in function foo at .*: i > 4.*(\n|\r\n|\r)" }
You can’t perform that action at this time.
0 commit comments