Skip to content

Commit 41e017f

Browse files
committed
testsuite, c++, contracts: Tests for P2900 3.4.3 part 1
1 parent 8695756 commit 41e017f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// { dg-options "-std=c++26 -fcontracts -fcontracts-nonattr" }
2+
3+
int bad_mr_shadow (int r)
4+
post (r: r > 5) // { dg-error "contract postcondition result names must not shadow function parameters" }
5+
{ return r + 1; }
6+
7+
auto no_deduced_res_types_on_non_defs (int x) // { dg-error "postconditions with deduced result name types must only appear on function definitions" }
8+
pre (x > 1)
9+
post (r: r > 17);
10+
11+
// =====
12+
13+
auto f2() post (r : r > 0) // OK, type of r is deduced below.
14+
{ return 5; }
15+
16+
template <typename T>
17+
auto f3 () post (r: r > 0); // OK, postcondition instantiated with template
18+
19+
auto f4 () post (true); // OK, return value not named

0 commit comments

Comments
 (0)