init.c (build_new_1): Call suspend_momentary around the creation of values that must be saved for...

* init.c (build_new_1): Call suspend_momentary around the creation
	of values that must be saved for exception handling.
	* parse.y (.build_new_placement): New non-terminal.
	(unary_expr, new_placement): Use it.
	* parse.c: Regenerated.

From-SVN: r19819
This commit is contained in:
Mark Mitchell 1998-05-17 13:58:28 +00:00 committed by Mark Mitchell
parent 0211b6ab9e
commit 1702d32ea7
4 changed files with 4013 additions and 3903 deletions

View File

@ -1,3 +1,11 @@
Sun May 17 13:53:48 1998 Mark Mitchell <mmitchell@usa.net>
* init.c (build_new_1): Call suspend_momentary around the creation
of values that must be saved for exception handling.
* parse.y (.build_new_placement): New non-terminal.
(unary_expr, new_placement): Use it.
* parse.c: Regenerated.
Sun May 17 12:32:08 1998 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (duplicate_decls): Use CANONICAL_TYPE_VARIANT to compare

View File

@ -2316,10 +2316,20 @@ build_new_1 (exp)
}
else
{
int susp;
if (flag_exceptions)
/* We will use RVAL when generating an exception handler for
this new-expression, so we must save it. */
susp = suspend_momentary ();
rval = build_op_new_call
(code, true_type, expr_tree_cons (NULL_TREE, size, placement),
LOOKUP_NORMAL | (use_global_new * LOOKUP_GLOBAL));
rval = cp_convert (build_pointer_type (true_type), rval);
if (flag_exceptions)
resume_momentary (susp);
}
/* unless an allocation function is declared with an empty excep-

File diff suppressed because it is too large Load Diff

View File

@ -243,7 +243,7 @@ empty_parms ()
%type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
%type <ttype> operator_name
%type <ttype> object aggr
%type <itype> new delete
%type <itype> new delete .begin_new_placement
/* %type <ttype> primary_no_id */
%type <ttype> nonmomentary_expr maybe_parmlist
%type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
@ -1031,16 +1031,29 @@ unary_expr:
| new new_placement new_type_id new_initializer
{ $$ = build_new ($2, $3.t, $4, $1);
check_for_new_type ("new", $3); }
| new '(' type_id ')' %prec EMPTY
{ $$ = build_new (NULL_TREE, groktypename($3.t),
/* The .begin_new_placement in the following rules is
necessary to avoid shift/reduce conflicts that lead to
mis-parsing some expressions. Of course, these constructs
are not really new-placement and it is bogus to call
begin_new_placement. But, the parser cannot always tell at this
point whether the next thing is an expression or a type-id,
so there is nothing we can do. Fortunately,
begin_new_placement does nothing harmful. When we rewrite
the parser, this lossage should be removed, of course. */
| new '(' .begin_new_placement type_id
{ finish_new_placement (NULL_TREE, $3); }
')' %prec EMPTY
{ $$ = build_new (NULL_TREE, groktypename($4.t),
NULL_TREE, $1);
check_for_new_type ("new", $3); }
| new '(' type_id ')' new_initializer
{ $$ = build_new (NULL_TREE, groktypename($3.t), $5, $1);
check_for_new_type ("new", $3); }
check_for_new_type ("new", $4); }
| new '(' .begin_new_placement type_id
{ finish_new_placement (NULL_TREE, $3); }
')' new_initializer
{ $$ = build_new (NULL_TREE, groktypename($4.t), $7, $1);
check_for_new_type ("new", $4); }
| new new_placement '(' type_id ')' %prec EMPTY
{ $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
check_for_new_type ("new", $4); }
check_for_new_type ("new", $4); }
| new new_placement '(' type_id ')' new_initializer
{ $$ = build_new ($2, groktypename($4.t), $6, $1);
check_for_new_type ("new", $4); }
@ -1061,16 +1074,19 @@ unary_expr:
{ $$ = build_x_unary_op (IMAGPART_EXPR, $2); }
;
.begin_new_placement:
{ $$ = begin_new_placement (); }
new_placement:
'('
{ $<itype>$ = begin_new_placement (); }
.begin_new_placement
nonnull_exprlist ')'
{ $$ = finish_new_placement ($3, $<itype>1); }
{ $$ = finish_new_placement ($3, $2); }
| '{'
{ cp_pedwarn ("old style placement syntax, use () instead");
$<itype>$ = begin_new_placement (); }
.begin_new_placement
nonnull_exprlist '}'
{ $$ = finish_new_placement ($3, $<itype>1); }
{ cp_pedwarn ("old style placement syntax, use () instead");
$$ = finish_new_placement ($3, $2); }
;
new_initializer:
@ -2552,14 +2568,17 @@ new_type_id:
{ $$.t = build_decl_list ($1.t, NULL_TREE);
$$.new_type_flag = $1.new_type_flag; }
/* GNU extension to allow arrays of arbitrary types with
non-constant dimension. */
| '(' type_id ')' '[' expr ']'
non-constant dimension. For the use of begin_new_placement
here, see the comments in unary_expr above. */
| '(' .begin_new_placement type_id
{ finish_new_placement (NULL_TREE, $2); }
')' '[' expr ']'
{
if (pedantic)
pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
$$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($2.t), $5);
$$.t = build_decl_list (TREE_PURPOSE ($2.t), $$.t);
$$.new_type_flag = $2.new_type_flag;
$$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $7);
$$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
$$.new_type_flag = $3.new_type_flag;
}
;