File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
gcc/testsuite/g++.dg/contracts/cpp26 Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments