The implicit constexpr patch revealed that we were doing constant evaluation
of arbitrary expressions in unevaluated contexts, leading to failure when we
tried to evaluate e.g. a call to declval. This is wrong more generally;
only manifestly-constant-evaluated expressions should be evaluated within
an unevaluated operand.
Making this change revealed a case we were failing to mark as manifestly
constant-evaluated.
gcc/cp/ChangeLog:
* constexpr.c (maybe_constant_value): Don't evaluate
in an unevaluated operand unless manifestly const-evaluated.
(fold_non_dependent_expr_template): Likewise.
* decl.c (compute_array_index_type_loc): This context is
manifestly constant-evaluated.
return r;
}
+ /* Don't evaluate an unevaluated operand. */
+ if (cp_unevaluated_operand)
+ return t;
+
uid_sensitive_constexpr_evaluation_checker c;
r = cxx_eval_outermost_constant_expr (t, true, true, false, false, decl);
gcc_checking_assert (r == t
return t;
}
+ if (cp_unevaluated_operand && !manifestly_const_eval)
+ return t;
+
tree r = cxx_eval_outermost_constant_expr (t, true, true,
manifestly_const_eval,
false, object);
cp_convert (ssizetype, integer_one_node,
complain),
complain);
- itype = maybe_constant_value (itype);
+ itype = maybe_constant_value (itype, NULL_TREE, true);
}
if (!TREE_CONSTANT (itype))