call.c (convert_like_real): Build up the initializer_list object directly.
authorJason Merrill <jason@redhat.com>
Wed, 30 Mar 2011 18:07:01 +0000 (14:07 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 30 Mar 2011 18:07:01 +0000 (14:07 -0400)
* 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

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/decl.c

index c282992..1b96aa4 100644 (file)
@@ -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.
 
index f7d108f..ad2de43 100644 (file)
@@ -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:
index d9c9ad8..bbccb67 100644 (file)
@@ -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;
 }