From 08f594eb399dab0637b57b0ca4b0a5ce912b8171 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Wed, 8 Jan 2020 15:31:25 -0500 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/constexpr.c | 1 + gcc/cp/cp-gimplify.c | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7aacbe2334b..210ab4e619f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-08 Jason Merrill + + * 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 PR c++/91369 - constexpr destructor and member initializer. diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 5fe6d0277b6..9306a7dce4a 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -5312,6 +5312,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t, *non_constant_p = true; break; } + gcc_checking_assert (!TARGET_EXPR_DIRECT_INIT_P (t)); /* Avoid evaluating a TARGET_EXPR more than once. */ if (tree *p = ctx->global->values.get (TARGET_EXPR_SLOT (t))) { diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c index 1d2a77d2c0a..827d240d11a 100644 --- a/gcc/cp/cp-gimplify.c +++ b/gcc/cp/cp-gimplify.c @@ -925,6 +925,13 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p) } 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: if (TREE_OPERAND (*expr_p, 0) && (TREE_CODE (TREE_OPERAND (*expr_p, 0)) == INIT_EXPR -- 2.30.2