static cp_expr cp_parser_expression
(cp_parser *, cp_id_kind * = NULL, bool = false, bool = false, bool = false);
static cp_expr cp_parser_constant_expression
- (cp_parser *, bool = false, bool * = NULL, bool = false);
+ (cp_parser *, int = 0, bool * = NULL, bool = false);
static cp_expr cp_parser_builtin_offsetof
(cp_parser *);
static cp_expr cp_parser_lambda_expression
If ALLOW_NON_CONSTANT_P a non-constant expression is silently
accepted. If ALLOW_NON_CONSTANT_P is true and the expression is not
constant, *NON_CONSTANT_P is set to TRUE. If ALLOW_NON_CONSTANT_P
- is false, NON_CONSTANT_P should be NULL. If STRICT_P is true,
+ is false, NON_CONSTANT_P should be NULL. If ALLOW_NON_CONSTANT_P is
+ greater than 1, this isn't really a constant-expression, only a
+ potentially constant-evaluated expression. If STRICT_P is true,
only parse a conditional-expression, otherwise parse an
assignment-expression. See below for rationale. */
static cp_expr
cp_parser_constant_expression (cp_parser* parser,
- bool allow_non_constant_p,
+ int allow_non_constant_p,
bool *non_constant_p,
bool strict_p)
{
parser->allow_non_integral_constant_expression_p
= (allow_non_constant_p || cxx_dialect >= cxx11);
parser->non_integral_constant_expression_p = false;
+
+ /* A manifestly constant-evaluated expression is evaluated even in an
+ unevaluated operand. */
+ cp_evaluated ev (/*reset if*/allow_non_constant_p <= 1);
+
/* Although the grammar says "conditional-expression", when not STRICT_P,
we parse an "assignment-expression", which also permits
"throw-expression" and the use of assignment operators. In the case
{
initializer
= cp_parser_constant_expression (parser,
- /*allow_non_constant_p=*/true,
+ /*allow_non_constant_p=*/2,
non_constant_p);
}
else
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,
}
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. */