Skip to content

Commit a5a7368

Browse files
committed
review round 2
1 parent e5a7167 commit a5a7368

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

gcc/cp/contracts.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2730,7 +2730,8 @@ tree view_as_const(tree decl)
27302730
ctype = cp_build_qualified_type (ctype, (cp_type_quals (ctype)
27312731
| TYPE_QUAL_CONST));
27322732
decl = build1 (VIEW_CONVERT_EXPR, ctype, decl);
2733-
CONTRACT_CONSTIFY_EXPR_P(decl) = true;
2733+
/* Mark the VCE as contract const wrapper. */
2734+
decl->base.private_flag = true;
27342735
}
27352736
return decl;
27362737
}

gcc/cp/cp-tree.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3204,12 +3204,6 @@ struct GTY(()) lang_decl {
32043204
#define CONTRACT_HELPER(NODE) \
32053205
(LANG_DECL_FN_CHECK (NODE)->contract_helper)
32063206

3207-
/* In VIEW_CONVERT_EXPR, set when this node is a const wrapper. Used to
3208-
constify entities inside contract assertions. */
3209-
3210-
#define CONTRACT_CONSTIFY_EXPR_P(NODE) \
3211-
(TREE_CHECK(NODE, VIEW_CONVERT_EXPR)->base.private_flag)
3212-
32133207
/* For a FUNCTION_DECL or a VAR_DECL, the language linkage for the
32143208
declaration. Some entities (like a member function in a local
32153209
class, or a local variable) do not have linkage at all, and this
@@ -9012,19 +9006,17 @@ set_contract_const (tree t, bool constify)
90129006
inline bool
90139007
contract_const_wrapper_p (const_tree exp)
90149008
{
9015-
/* A wrapper node has code VIEW_CONVERT_EXPR, and the flag
9016-
EXPR_LOCATION_WRAPPER_P is set. */
9017-
if (TREE_CODE (exp) == VIEW_CONVERT_EXPR
9018-
&& CONTRACT_CONSTIFY_EXPR_P (exp))
9019-
return true;
9020-
return false;
9009+
/* A wrapper node has code VIEW_CONVERT_EXPR, and the flag base.private_flag
9010+
is set. The wrapper node is used to Used to constify entities inside
9011+
contract assertions. */
9012+
return ((TREE_CODE (exp) == VIEW_CONVERT_EXPR) && exp->base.private_flag);
90219013
}
90229014

9023-
/* If EXP is a CONTRACT_CONSTIFY_EXPR_P, return the wrapped expression.
9015+
/* If EXP is a contract_const_wrapper_p, return the wrapped expression.
90249016
Otherwise, do nothing. */
90259017

90269018
inline tree
9027-
strip_contract_constify_expr (tree exp)
9019+
strip_contract_const_wrapper (tree exp)
90289020
{
90299021
if (contract_const_wrapper_p (exp))
90309022
return TREE_OPERAND (exp, 0);

gcc/cp/semantics.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12597,7 +12597,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p,
1259712597
strip the const wrapper. Per P2900R14, "For a function f with the
1259812598
return type T , the result name is an lvalue of type const T , decltype(r)
1259912599
is T , and decltype((r)) is const T&." */
12600-
expr = strip_contract_constify_expr (expr);
12600+
expr = strip_contract_const_wrapper (expr);
1260112601

1260212602
if (INDIRECT_REF_P (expr)
1260312603
|| TREE_CODE (expr) == VIEW_CONVERT_EXPR)

gcc/tree-core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1364,7 +1364,7 @@ struct GTY(()) tree_base {
13641364
ENUM_IS_OPAQUE in
13651365
ENUMERAL_TYPE
13661366
1367-
EXPR_CONTRACT_CONST_WRAPPER_P in
1367+
contract_const_wrapper_p in
13681368
VIEW_CONVERT_EXPR
13691369
13701370
protected_flag:

0 commit comments

Comments
 (0)