From cb43d570ae491dc1254e20507b8ad7ebd2586233 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Mar 2011 18:07:01 +0000 Subject: [PATCH] * call.c (convert_like_real) [ck_list]: Build up the initializer_list object directly. * decl.c (build_init_list_var_init): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@171740 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 22 ++++++++++------------ gcc/cp/decl.c | 4 ++-- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index c282992..1b96aa4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-03-30 Jason Merrill + * call.c (convert_like_real) [ck_list]: Build up the + initializer_list object directly. + * decl.c (build_init_list_var_init): Adjust. + * call.c (convert_like_real): Correct TREE_CONSTANT on CONSTRUCTOR. * decl.c (reshape_init_array_1): Likewise. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index f7d108f..ad2de43 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5467,8 +5467,8 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, tree elttype = TREE_VEC_ELT (CLASSTYPE_TI_ARGS (totype), 0); tree new_ctor = build_constructor (init_list_type_node, NULL); unsigned len = CONSTRUCTOR_NELTS (expr); - tree array, val; - VEC(tree,gc) *parms; + tree array, val, field; + VEC(constructor_elt,gc) *vec = NULL; unsigned ix; /* Convert all the elements. */ @@ -5490,16 +5490,14 @@ convert_like_real (conversion *convs, tree expr, tree fn, int argnum, array = build_array_of_n_type (elttype, len); array = finish_compound_literal (array, new_ctor); - parms = make_tree_vector (); - VEC_safe_push (tree, gc, parms, decay_conversion (array)); - VEC_safe_push (tree, gc, parms, size_int (len)); - /* Call the private constructor. */ - push_deferring_access_checks (dk_no_check); - new_ctor = build_special_member_call - (NULL_TREE, complete_ctor_identifier, &parms, totype, 0, complain); - release_tree_vector (parms); - pop_deferring_access_checks (); - return build_cplus_new (totype, new_ctor); + /* Build up the initializer_list object. */ + totype = complete_type (totype); + field = next_initializable_field (TYPE_FIELDS (totype)); + CONSTRUCTOR_APPEND_ELT (vec, field, decay_conversion (array)); + field = next_initializable_field (DECL_CHAIN (field)); + CONSTRUCTOR_APPEND_ELT (vec, field, size_int (len)); + new_ctor = build_constructor (totype, vec); + return get_target_expr (new_ctor); } case ck_aggr: diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index d9c9ad8..bbccb67 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -4562,7 +4562,7 @@ build_init_list_var_init (tree decl, tree type, tree init, tree *array_init, return error_mark_node; aggr_init = TARGET_EXPR_INITIAL (init); - array = AGGR_INIT_EXPR_ARG (aggr_init, 1); + array = CONSTRUCTOR_ELT (aggr_init, 0)->value; arrtype = TREE_TYPE (array); STRIP_NOPS (array); gcc_assert (TREE_CODE (array) == ADDR_EXPR); @@ -4574,7 +4574,7 @@ build_init_list_var_init (tree decl, tree type, tree init, tree *array_init, tree var = set_up_extended_ref_temp (decl, array, cleanup, array_init); var = build_address (var); var = convert (arrtype, var); - AGGR_INIT_EXPR_ARG (aggr_init, 1) = var; + CONSTRUCTOR_ELT (aggr_init, 0)->value = var; } return init; } -- 2.7.4