From 338976c2341aa9e89007338976546b9d907619db Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Thu, 8 Oct 2015 12:14:03 -0400 Subject: [PATCH] cp-tree.h (SIMPLE_TARGET_EXPR_P): New. * cp-tree.h (SIMPLE_TARGET_EXPR_P): New. * init.c (get_nsdmi): Use it. * typeck2.c (massage_init_elt): Use it. From-SVN: r228606 --- gcc/cp/ChangeLog | 6 ++++++ gcc/cp/cp-tree.h | 6 ++++++ gcc/cp/init.c | 3 +-- gcc/cp/typeck2.c | 3 +-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index bf9b0c29971..e89fd022933 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-10-08 Jason Merrill + + * cp-tree.h (SIMPLE_TARGET_EXPR_P): New. + * init.c (get_nsdmi): Use it. + * typeck2.c (massage_init_elt): Use it. + 2015-10-07 Jason Merrill PR c++/67557 diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 5acb065aba0..f650c76c902 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4490,6 +4490,12 @@ more_aggr_init_expr_args_p (const aggr_init_expr_arg_iterator *iter) #define TARGET_EXPR_DIRECT_INIT_P(NODE) \ TREE_LANG_FLAG_2 (TARGET_EXPR_CHECK (NODE)) +/* True if NODE is a TARGET_EXPR that just expresses a copy of its INITIAL; if + the initializer has void type, it's doing something more complicated. */ +#define SIMPLE_TARGET_EXPR_P(NODE) \ + (TREE_CODE (NODE) == TARGET_EXPR \ + && !VOID_TYPE_P (TREE_TYPE (TARGET_EXPR_INITIAL (NODE)))) + /* True if EXPR expresses direct-initialization of a TYPE. */ #define DIRECT_INIT_EXPR_P(TYPE,EXPR) \ (TREE_CODE (EXPR) == TARGET_EXPR && TREE_LANG_FLAG_2 (EXPR) \ diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 1ed8f6c625e..57a64068351 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -588,8 +588,7 @@ get_nsdmi (tree member, bool in_ctor) } /* Strip redundant TARGET_EXPR so we don't need to remap it, and so the aggregate init code below will see a CONSTRUCTOR. */ - if (init && TREE_CODE (init) == TARGET_EXPR - && !VOID_TYPE_P (TREE_TYPE (TARGET_EXPR_INITIAL (init)))) + if (init && SIMPLE_TARGET_EXPR_P (init)) init = TARGET_EXPR_INITIAL (init); init = break_out_target_exprs (init); } diff --git a/gcc/cp/typeck2.c b/gcc/cp/typeck2.c index 1d106c74995..2c9143e63a2 100644 --- a/gcc/cp/typeck2.c +++ b/gcc/cp/typeck2.c @@ -1208,8 +1208,7 @@ massage_init_elt (tree type, tree init, tsubst_flags_t complain) { init = digest_init_r (type, init, true, LOOKUP_IMPLICIT, complain); /* Strip a simple TARGET_EXPR when we know this is an initializer. */ - if (TREE_CODE (init) == TARGET_EXPR - && !VOID_TYPE_P (TREE_TYPE (TARGET_EXPR_INITIAL (init)))) + if (SIMPLE_TARGET_EXPR_P (init)) init = TARGET_EXPR_INITIAL (init); /* When we defer constant folding within a statement, we may want to defer this folding as well. */ -- 2.30.2