forked from gcc-mirror/gcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request gcc-mirror#56 from iains/contracts-nonattr-p2900-3…
…-4-3 Contracts nonattr p2900 3 4 3
- Loading branch information
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// { dg-options "-std=c++26 -fcontracts -fcontracts-nonattr" } | ||
|
||
int bad_mr_shadow (int r) | ||
post (r: r > 5) // { dg-error "contract postcondition result names must not shadow function parameters" } | ||
{ return r + 1; } | ||
|
||
auto no_deduced_res_types_on_non_defs (int x) // { dg-error "postconditions with deduced result name types must only appear on function definitions" } | ||
pre (x > 1) | ||
post (r: r > 17); | ||
|
||
// ===== | ||
|
||
auto f2() post (r : r > 0) // OK, type of r is deduced below. | ||
{ return 5; } | ||
|
||
template <typename T> | ||
auto f3 () post (r: r > 0); // OK, postcondition instantiated with template | ||
|
||
auto f4 () post (true); // OK, return value not named |