diff options
author | Jason Merrill <jason@redhat.com> | 2020-03-05 15:50:45 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2022-01-06 19:23:17 -0500 |
commit | 4f6bc28fc7dd86bd9e7408cbf28de1e973dd1eda (patch) | |
tree | 0a38c0720e5d43cd717dbef2244dad9d139dd830 /gcc/cp/tree.c | |
parent | beaee0a871b6485d20573fe050b1fd425581e56a (diff) | |
download | gcc-4f6bc28fc7dd86bd9e7408cbf28de1e973dd1eda.zip gcc-4f6bc28fc7dd86bd9e7408cbf28de1e973dd1eda.tar.gz gcc-4f6bc28fc7dd86bd9e7408cbf28de1e973dd1eda.tar.bz2 |
c++: EH and partially constructed aggr temp [PR66139]
Now that PR94041 is fixed, I can return to addressing PR66139, missing
cleanups for partially constructed aggregate temporaries. My previous
approach of calling split_nonconstant_init in cp_gimplify_init_expr broke
because gimplification is too late to be introducing destructor calls. So
instead I now call it under cp_fold_function, just before cp_genericize;
doing it from cp_genericize itself ran into trouble with the rewriting of
invisible references.
So now the prediction in cp_gimplify_expr that cp_gimplify_init_expr
might need to replace references to TARGET_EXPR_SLOT within
TARGET_EXPR_INITIAL has come to pass. constexpr.c already had the simple
search-and-replace tree walk I needed, but it needed to be fixed to actually
replace all occurrences instead of just the first one.
Handling of VEC_INIT_EXPR at gimplify time had similar issues that we worked
around with build_vec_init_elt, so I'm moving that to cp_fold_function as
well. But it seems that build_vec_init_elt is still useful for setting the
VEC_INIT_EXPR_IS_CONSTEXPR flag, so I'm leaving it alone.
This also fixes 52320, because build_aggr_init of each X from build_vec_init
builds an INIT_EXPR rather than call split_nonconstant_init at that point,
and now that INIT_EXPR gets split later.
PR c++/66139
PR c++/52320
gcc/cp/ChangeLog:
* constexpr.c (replace_decl): Rename from replace_result_decl.
* cp-tree.h (replace_decl): Declare it.
* cp-gimplify.c (cp_gimplify_init_expr): Call it.
(cp_gimplify_expr): Don't handle VEC_INIT_EXPR.
(cp_genericize_init, cp_genericize_init_expr)
(cp_genericize_target_expr): New.
(cp_fold_r): Call them.
* tree.c (build_array_copy): Add a TARGET_EXPR.
* typeck2.c (digest_init_r): Look through a TARGET_EXPR.
gcc/testsuite/ChangeLog:
* g++.dg/cpp0x/initlist116.C: New test.
* g++.dg/cpp0x/initlist117.C: New test.
* g++.dg/cpp0x/lambda/lambda-eh.C: New test.
* g++.dg/eh/aggregate1.C: New test.
Diffstat (limited to 'gcc/cp/tree.c')
-rw-r--r-- | gcc/cp/tree.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 964e40e..4c1135b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -737,12 +737,12 @@ build_cplus_new (tree type, tree init, tsubst_flags_t complain) intialization as a proxy for the full array initialization to get things marked as used and any appropriate diagnostics. - Since we're deferring building the actual constructor calls until - gimplification time, we need to build one now and throw it away so - that the relevant constructor gets mark_used before cgraph decides - what functions are needed. Here we assume that init is either - NULL_TREE, void_type_node (indicating value-initialization), or - another array to copy. */ + This used to be necessary because we were deferring building the actual + constructor calls until gimplification time; now we only do it to set + VEC_INIT_EXPR_IS_CONSTEXPR. + + We assume that init is either NULL_TREE, void_type_node (indicating + value-initialization), or another array to copy. */ static tree build_vec_init_elt (tree type, tree init, tsubst_flags_t complain) @@ -858,7 +858,8 @@ diagnose_non_constexpr_vec_init (tree expr) tree build_array_copy (tree init) { - return build_vec_init_expr (TREE_TYPE (init), init, tf_warning_or_error); + return get_target_expr (build_vec_init_expr + (TREE_TYPE (init), init, tf_warning_or_error)); } /* Build a TARGET_EXPR using INIT to initialize a new temporary of the |