Commit 02a8575c by Jason Merrill Committed by Jason Merrill

Handle constexpr conversion from and then to the same type.

	* constexpr.c (cxx_eval_constant_expression): Handle conversion from
	and then to the same type.

From-SVN: r272429
parent 3da7d774
2019-06-18 Jason Merrill <jason@redhat.com>
* constexpr.c (cxx_eval_constant_expression): Handle conversion from
and then to the same type.
2019-06-18 Jason Merrill <jason@redhat.com>
* constexpr.c (unshare_constructor): Add MEM_STAT_DECL.
2019-06-17 Jakub Jelinek <jakub@redhat.com>
......
......@@ -5034,6 +5034,10 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
if (*non_constant_p)
return t;
tree type = TREE_TYPE (t);
if (VOID_TYPE_P (type))
return void_node;
if (TREE_CODE (op) == PTRMEM_CST
&& !TYPE_PTRMEM_P (type))
op = cplus_expand_constant (op);
......@@ -5094,14 +5098,18 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
conversion. */
return fold (t);
tree sop;
/* Handle an array's bounds having been deduced after we built
the wrapping expression. */
if (same_type_ignoring_tlq_and_bounds_p (type, TREE_TYPE (op)))
r = op;
else if (sop = tree_strip_nop_conversions (op),
sop != op && (same_type_ignoring_tlq_and_bounds_p
(type, TREE_TYPE (sop))))
r = sop;
else if (tcode == UNARY_PLUS_EXPR)
r = fold_convert (TREE_TYPE (t), op);
else if (VOID_TYPE_P (type))
r = void_node;
else
r = fold_build1 (tcode, type, op);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment