Commit 08f594eb by Jason Merrill Committed by Jason Merrill

Add TARGET_EXPR_DIRECT_INIT_P sanity check.

	* cp-gimplify.c (cp_gimplify_expr) [TARGET_EXPR]: Check
	TARGET_EXPR_DIRECT_INIT_P.
	* constexpr.c (cxx_eval_constant_expression): Likewise.

From-SVN: r280019
parent 10d2f801
2020-01-08 Jason Merrill <jason@redhat.com> 2020-01-08 Jason Merrill <jason@redhat.com>
* cp-gimplify.c (cp_gimplify_expr) [TARGET_EXPR]: Check
TARGET_EXPR_DIRECT_INIT_P.
* constexpr.c (cxx_eval_constant_expression): Likewise.
2020-01-08 Jason Merrill <jason@redhat.com>
PR c++/91369 - constexpr destructor and member initializer. PR c++/91369 - constexpr destructor and member initializer.
* constexpr.c (cxx_eval_store_expression): Look through TARGET_EXPR * constexpr.c (cxx_eval_store_expression): Look through TARGET_EXPR
when not preevaluating. when not preevaluating.
......
...@@ -5312,6 +5312,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, ...@@ -5312,6 +5312,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
*non_constant_p = true; *non_constant_p = true;
break; break;
} }
gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (t));
/* Avoid evaluating a TARGET_EXPR more than once. */ /* Avoid evaluating a TARGET_EXPR more than once. */
if (tree *p = ctx->global->values.get (TARGET_EXPR_SLOT (t))) if (tree *p = ctx->global->values.get (TARGET_EXPR_SLOT (t)))
{ {
......
...@@ -925,6 +925,13 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) ...@@ -925,6 +925,13 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
} }
break; break;
case TARGET_EXPR:
/* A TARGET_EXPR that expresses direct-initialization should have been
elided by cp_gimplify_init_expr. */
gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (*expr_p));
ret = GS_UNHANDLED;
break;
case RETURN_EXPR: case RETURN_EXPR:
if (TREE_OPERAND (*expr_p, 0) if (TREE_OPERAND (*expr_p, 0)
&& (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == INIT_EXPR && (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == INIT_EXPR
......
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