From a9fc64d8120937c5c37e1cacb2f55ae196e8897d Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 14 Apr 2021 11:24:50 -0400 Subject: c++: constant expressions are evaluated [PR93314] My GCC 11 patch for PR93314 turned off cp_unevaluated_operand while processing an id-expression that names a non-static data member, but the broader issue is that in general, a constant-expression is evaluated even in an unevaluated operand. gcc/cp/ChangeLog: * cp-tree.h (cp_evaluated): Add reset parm to constructor. * parser.c (cp_parser_constant_expression): Change allow_non_constant_p to int. Use cp_evaluated. (cp_parser_initializer_clause): Pass 2 to allow_non_constant_p. * semantics.c (finish_id_expression_1): Don't mess with cp_unevaluated_operand here. --- gcc/cp/semantics.c | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 319a3a8..6224f49 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4097,12 +4097,6 @@ finish_id_expression_1 (tree id_expression, cp_warn_deprecated_use_scopes (scope); - /* In a constant-expression context, turn off cp_unevaluated_operand - so finish_non_static_data_member will complain (93314). */ - auto eval = make_temp_override (cp_unevaluated_operand); - if (integral_constant_expression_p && TREE_CODE (decl) == FIELD_DECL) - cp_unevaluated_operand = 0; - if (TYPE_P (scope)) decl = finish_qualified_id_expr (scope, decl, @@ -4116,10 +4110,6 @@ finish_id_expression_1 (tree id_expression, } else if (TREE_CODE (decl) == FIELD_DECL) { - auto eval = make_temp_override (cp_unevaluated_operand); - if (integral_constant_expression_p) - cp_unevaluated_operand = 0; - /* Since SCOPE is NULL here, this is an unqualified name. Access checking has been performed during name lookup already. Turn off checking to avoid duplicate errors. */ -- cgit v1.1