Debian Codegraph @

gcc/testsuite/g++.dg/contracts/contracts-post7.C

raw
1 // { dg-do run }
2 // { dg-options "-std=c++2a -fcontracts" }
3 /* { dg-skip-if "requires hosted libstdc++ for cwchar" { ! hostedlib } } */
4
5 #include <experimental/contract>
6
7 using std::experimental::contract_violation;
8 void handle_contract_violation(const contract_violation &violation)
9 {
10 __builtin_exit (0);
11 }
12
13 struct A {
14 int i;
15 A(): i(42) {}
16 A(const A&);
17 };
18
19 A f()
20 [[ post r: r.i == 24 ]]
21 {
22 A a;
23 return a;
24 }
25
26 int main()
27 {
28 f();
29 return -1;
30 }