Skip to content

Commit a10fabd

Browse files
NinaRannsiains
authored andcommitted
adding missing test for contract definition side check
1 parent 2504654 commit a10fabd

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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)" }

0 commit comments

Comments
 (0)