aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2011-03-30 14:07:01 -0400
committerJason Merrill <jason@gcc.gnu.org>2011-03-30 14:07:01 -0400
commit88d37ae679fd5fd498076514d16248ccb5b2b8ae (patch)
treed9f61b06c2f15ce0e6a3351669a277539f4f6fee /gcc
parentc06ce6e40ed1ce4d9835d10e6a7d667fb6b30587 (diff)
downloadgcc-88d37ae679fd5fd498076514d16248ccb5b2b8ae.zip
gcc-88d37ae679fd5fd498076514d16248ccb5b2b8ae.tar.gz
gcc-88d37ae679fd5fd498076514d16248ccb5b2b8ae.tar.bz2
call.c (convert_like_real): Build up the initializer_list object directly.
* call.c (convert_like_real) [ck_list]: Build up the initializer_list object directly. * decl.c (build_init_list_var_init): Adjust. From-SVN: r171740
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog4
-rw-r--r--gcc/cp/call.c22
-rw-r--r--gcc/cp/decl.c4
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 <jason@redhat.com>
+ * 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;
}