diff options
author | Jason Merrill <jason@redhat.com> | 2018-11-05 02:46:57 -0500 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2018-11-05 02:46:57 -0500 |
commit | 5dab8b11c41fe72ea606c38884f7730bd2aeafdc (patch) | |
tree | 93c5972f6c8b0ac891b9a3d2e0afdc8eda67bf8e /gcc/cp/cvt.c | |
parent | c24c8a4b003f81734c2a94e0980008c2c24659d9 (diff) | |
download | gcc-5dab8b11c41fe72ea606c38884f7730bd2aeafdc.zip gcc-5dab8b11c41fe72ea606c38884f7730bd2aeafdc.tar.gz gcc-5dab8b11c41fe72ea606c38884f7730bd2aeafdc.tar.bz2 |
Fix various latent issues revealed by P0732 work.
The initialized_type hunk fixes handling of void AGGR_INIT_EXPRs that call a
non-constructor; an AGGR_INIT_EXPR can have void type if its initialization
semantics are more complicated than just expanding the call.
The cxx_eval_vec_init_1 hunk corrects AGGR_INIT_EXPRs that were
nonsensically built to initialize an object of void type. And the
build_aggr_init_expr hunk makes sure we don't do that again.
The ocp_convert and cxx_eval_outermost_constant_expr hunks deal with making
sure that a constant CONSTRUCTOR has the right type.
* cvt.c (ocp_convert): Don't wrap a CONSTRUCTOR in a NOP_EXPR.
* constexpr.c (initialized_type): Fix AGGR_INIT_EXPR handling.
(cxx_eval_vec_init_1): Correct type of AGGR_INIT_EXPR.
(cxx_eval_outermost_constant_expr): Make sure a CONSTRUCTOR has the
right type. Don't wrap a CONSTRUCTOR if one was passed in.
* tree.c (build_aggr_init_expr): Check for void.
From-SVN: r265788
Diffstat (limited to 'gcc/cp/cvt.c')
-rw-r--r-- | gcc/cp/cvt.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/cp/cvt.c b/gcc/cp/cvt.c index 315b0d6..b04e9a7 100644 --- a/gcc/cp/cvt.c +++ b/gcc/cp/cvt.c @@ -725,7 +725,8 @@ ocp_convert (tree type, tree expr, int convtype, int flags, /* We need a new temporary; don't take this shortcut. */; else if (same_type_ignoring_top_level_qualifiers_p (type, TREE_TYPE (e))) { - if (same_type_p (type, TREE_TYPE (e))) + tree etype = TREE_TYPE (e); + if (same_type_p (type, etype)) /* The call to fold will not always remove the NOP_EXPR as might be expected, since if one of the types is a typedef; the comparison in fold is just equality of pointers, not a @@ -743,9 +744,16 @@ ocp_convert (tree type, tree expr, int convtype, int flags, { /* Don't build a NOP_EXPR of class type. Instead, change the type of the temporary. */ + gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, etype)); TREE_TYPE (e) = TREE_TYPE (TARGET_EXPR_SLOT (e)) = type; return e; } + else if (TREE_CODE (e) == CONSTRUCTOR) + { + gcc_assert (same_type_ignoring_top_level_qualifiers_p (type, etype)); + TREE_TYPE (e) = type; + return e; + } else { /* We shouldn't be treating objects of ADDRESSABLE type as |