Commit f30efcb7 by Jason Merrill Committed by Jason Merrill

init.c (build_default_init): New fn.

        * init.c (build_default_init): New fn.
        (perform_member_init): Split out from here.
        (build_new_1): Use it.  Simplify initialization logic.
        (build_vec_init): Take an array, rather than a pointer and maxindex.
        Speed up simple initializations.  Don't clean up if we're assigning.
        * cp-tree.h: Adjust.
        * decl2.c (do_static_initialization): Remove TREE_VEC case.
        * parse.y (new_initializer): Return void_zero_node for ().
        * typeck.c (build_modify_expr): Handle getting a CONSTRUCTOR.
        * typeck2.c (digest_init): Only complain about user-written
        CONSTRUCTORs.

From-SVN: r38643
parent a412bf75
2001-01-03 Jason Merrill <jason@redhat.com>
* init.c (build_default_init): New fn.
(perform_member_init): Split out from here.
(build_new_1): Use it. Simplify initialization logic.
(build_vec_init): Take an array, rather than a pointer and maxindex.
Speed up simple initializations. Don't clean up if we're assigning.
* cp-tree.h: Adjust.
* decl2.c (do_static_initialization): Remove TREE_VEC case.
* parse.y (new_initializer): Return void_zero_node for ().
* typeck.c (build_modify_expr): Handle getting a CONSTRUCTOR.
* typeck2.c (digest_init): Only complain about user-written
CONSTRUCTORs.
2000-12-22 Mike Stump <mrs@wrs.com>
* decl2.c: (max_tinst_depth): Increase to 50.
......
......@@ -4047,7 +4047,7 @@ extern tree build_member_call PARAMS ((tree, tree, tree));
extern tree build_offset_ref PARAMS ((tree, tree));
extern tree resolve_offset_ref PARAMS ((tree));
extern tree build_new PARAMS ((tree, tree, tree, int));
extern tree build_vec_init PARAMS ((tree, tree, tree, tree, int));
extern tree build_vec_init PARAMS ((tree, tree, int));
extern tree build_x_delete PARAMS ((tree, int, tree));
extern tree build_delete PARAMS ((tree, tree, special_function_kind, int, int));
extern tree build_vbase_delete PARAMS ((tree, tree));
......
......@@ -3394,10 +3394,6 @@ do_static_initialization (decl, init)
if (IS_AGGR_TYPE (TREE_TYPE (decl))
|| TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
expr = build_aggr_init (decl, init, 0);
else if (TREE_CODE (init) == TREE_VEC)
expr = build_vec_init (decl, TREE_VEC_ELT (init, 0),
TREE_VEC_ELT (init, 1),
TREE_VEC_ELT (init, 2), 0);
else
{
expr = build (INIT_EXPR, TREE_TYPE (decl), decl, init);
......
......@@ -1268,7 +1268,7 @@ new_initializer:
'(' nonnull_exprlist ')'
{ $$ = $2; }
| LEFT_RIGHT
{ $$ = NULL_TREE; }
{ $$ = void_zero_node; }
| '(' typespec ')'
{
cp_error ("`%T' is not a valid expression", $2.t);
......
......@@ -5627,7 +5627,15 @@ build_modify_expr (lhs, modifycode, rhs)
if (modifycode == INIT_EXPR)
{
if (! IS_AGGR_TYPE (lhstype))
if (TREE_CODE (rhs) == CONSTRUCTOR)
{
if (! same_type_p (TREE_TYPE (rhs), lhstype))
abort ();
result = build (INIT_EXPR, lhstype, lhs, rhs);
TREE_SIDE_EFFECTS (result) = 1;
return result;
}
else if (! IS_AGGR_TYPE (lhstype))
/* Do the default thing */;
else
{
......@@ -5808,9 +5816,7 @@ build_modify_expr (lhs, modifycode, rhs)
from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
? 1 + (modifycode != INIT_EXPR): 0;
return (build_vec_init
(lhs, lhs, array_type_nelts (lhstype), newrhs,
from_array));
return build_vec_init (lhs, newrhs, from_array);
}
if (modifycode == INIT_EXPR)
......
......@@ -581,7 +581,8 @@ digest_init (type, init, tail)
if (code == ARRAY_TYPE || IS_AGGR_TYPE_CODE (code))
{
if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type))
if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type)
&& TREE_HAS_CONSTRUCTOR (init))
{
cp_error ("subobject of type `%T' must be initialized by constructor, not by `%E'",
type, init);
......
// Test that we properly default-initialize the new int when () is given.
// execution test - XFAIL *-*-*
#include <new>
using namespace std;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment