Skip to content

Commit a382c52

Browse files
committed
testsuite, c++, contracts: Testcase for out-of-class defns.
Signed-off-by: Iain Sandoe <[email protected]>
1 parent b27844e commit a382c52

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// { dg-options "-std=c++26 -fcontracts -fcontracts-nonattr" }
2+
3+
struct F {
4+
int a;
5+
F (int b)
6+
pre (b >= 0)
7+
post (this->a > 10);
8+
9+
~F () = default;
10+
11+
int swap (const int b)
12+
pre (b > 5)
13+
pre (a != 0)
14+
post (a == b) ;
15+
};
16+
17+
F::F (int b)
18+
pre (b >= 0)
19+
post (this->a > 10)
20+
: a (b)
21+
{}
22+
23+
int
24+
F::swap (const int b)
25+
pre (b > 5)
26+
pre (a != 0)
27+
post (a == b)
28+
{ int x = a; a = b; return x; }
29+
30+
#if 0
31+
int main ()
32+
{
33+
F f{0};
34+
f.swap (11);
35+
}
36+
#endif

0 commit comments

Comments
 (0)