Skip to content

Commit 11f7474

Browse files
Merge pull request gcc-mirror#76 from iains/contracts-nonattr-fix-noconst-in-postconditions
c++, contracts: Make sure we check const-ification is required on post.
2 parents 37b0ff4 + 1ea125f commit 11f7474

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

gcc/cp/contracts.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,6 +2763,7 @@ maybe_reject_param_in_postcondition (tree decl)
27632763
if (flag_contracts_nonattr
27642764
&& !TREE_READONLY (decl)
27652765
&& TREE_CODE (decl) == PARM_DECL
2766+
&& should_constify_contract
27662767
&& processing_postcondition
27672768
&& !dependent_type_p (TREE_TYPE (decl))
27682769
&& !CP_TYPE_CONST_P (TREE_TYPE (decl))
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// { dg-options "-std=c++23 -fcontracts -fcontracts-nonattr -fcontracts-nonattr-noconst" }
2+
3+
// This should compile without error.
4+
5+
class X {
6+
7+
static int calc ()
8+
post (alignment: 0 == (alignment & (alignment-1)));
9+
10+
};
11+

0 commit comments

Comments
 (0)