diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-04 12:54:08 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-04 12:54:08 +0000 |
commit | c7b89256f73ad16b147bec0176ebacf9ca8d9454 (patch) | |
tree | 2aea6e5048d38c60ba565aa04710e5fa10eeeadd /gcc/cp/init.c | |
parent | d306cbee92c9e9dc2bb4f4d013b713f2588a23e0 (diff) | |
download | gcc-c7b89256f73ad16b147bec0176ebacf9ca8d9454.tar.gz |
PR c++/48370
* call.c (extend_ref_init_temps, extend_ref_init_temps_1): New.
(set_up_extended_ref_temp): Use it. Change cleanup parm to VEC.
(initialize_reference): Just call convert_like.
* decl.c (grok_reference_init): Just call initialize_reference.
(build_init_list_var_init): Remove.
(check_initializer): Change cleanup parm to VEC. Handle references
like other types. Call perform_implicit_conversion instead
of build_init_list_var_init. Don't use build_aggr_init for
aggregate initialization of arrays.
(cp_finish_decl): Change cleanup to VEC.
* typeck2.c (store_init_value): Call extend_ref_init_temps.
Use build_vec_init for non-constant arrays.
* init.c (expand_aggr_init_1): Adjust.
(build_vec_init): Avoid re-converting an initializer
that's already digested.
* mangle.c (mangle_ref_init_variable): Add a discriminator.
* cp-tree.h: Adjust.
* typeck.c (convert_for_initialization): Adjust.
* decl2.c (maybe_emit_vtables): Adjust.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@180944 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/init.c')
-rw-r--r-- | gcc/cp/init.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ec7ba0e802a..38812754641 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1597,12 +1597,14 @@ expand_aggr_init_1 (tree binfo, tree true_exp, tree exp, tree init, int flags, if (init && TREE_CODE (exp) == VAR_DECL && COMPOUND_LITERAL_P (init)) { + VEC(tree,gc)* cleanups = NULL; /* If store_init_value returns NULL_TREE, the INIT has been recorded as the DECL_INITIAL for EXP. That means there's nothing more we have to do. */ - init = store_init_value (exp, init, flags); + init = store_init_value (exp, init, &cleanups, flags); if (init) finish_expr_stmt (init); + gcc_assert (!cleanups); return; } @@ -3150,6 +3152,9 @@ build_vec_init (tree base, tree maxindex, tree init, bool try_const = (TREE_CODE (atype) == ARRAY_TYPE && (literal_type_p (inner_elt_type) || TYPE_HAS_CONSTEXPR_CTOR (inner_elt_type))); + /* If the constructor already has the array type, it's been through + digest_init, so we shouldn't try to do anything more. */ + bool digested = same_type_p (atype, TREE_TYPE (init)); bool saw_non_const = false; bool saw_const = false; /* If we're initializing a static array, we want to do static @@ -3172,7 +3177,9 @@ build_vec_init (tree base, tree maxindex, tree init, num_initialized_elts++; current_stmt_tree ()->stmts_are_full_exprs_p = 1; - if (MAYBE_CLASS_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE) + if (digested) + one_init = build2 (INIT_EXPR, type, baseref, elt); + else if (MAYBE_CLASS_TYPE_P (type) || TREE_CODE (type) == ARRAY_TYPE) one_init = build_aggr_init (baseref, elt, 0, complain); else one_init = cp_build_modify_expr (baseref, NOP_EXPR, |