Commit 80048418 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (begin_new_placement): Remove.

	* cp-tree.h (begin_new_placement): Remove.
	(finish_new_placement): Likewise.
	* class.c (finish_struct_1): Don't suspend_momentary or
	resume_momentary.
	* decl.c (grokdeclarator): Likewise.
	(maybe_build_cleanup_1): Likewise.
	* except.c (push_eh_cleanup): Likewise.
	(build_terminate_handler): Likewise.
	* init.c (build_new_1): Likewise.
	* parse.y (parse_decl): Change prototype.
	(initdecls, notype_initdecls, initdcl): Don't return int.
	(initdcl0, notype_initdcl0, initdcl0_innards): Likewise.
	(.begin_new_placement): Remove.
	(.finish_new_placement): Likewise.
	(nonmomentary_expr): Likewise.
	(suspend_mom): Likewise.
	(condition): Don't suspend_momentary, resume_momentary, or keep
	track of need to resume.
	(unary_expr): Likewise.
	(new_placement): Likewise.
	(decl): Likewise.
	(structsp): Likewise.
	(new_type_id): Likewise.
	(maybe_parmlist): Likewise.
	(direct_after_type_declaration): Likewise.
	(direct_new_declarator): Likewise.
	(direct_abstract_declaration): Likewise.
	* parse.c: Regenerated.
	* pt.c (tsubst_expr): Don't suspend_momentary or resume_momentary.
	* semantics.c (begin_new_placement): Remove.
	(finish_new_placement): Likewise.

From-SVN: r30443
parent 1aecd750
1999-11-07 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (begin_new_placement): Remove.
(finish_new_placement): Likewise.
* class.c (finish_struct_1): Don't suspend_momentary or
resume_momentary.
* decl.c (grokdeclarator): Likewise.
(maybe_build_cleanup_1): Likewise.
* except.c (push_eh_cleanup): Likewise.
(build_terminate_handler): Likewise.
* init.c (build_new_1): Likewise.
* parse.y (parse_decl): Change prototype.
(initdecls, notype_initdecls, initdcl): Don't return int.
(initdcl0, notype_initdcl0, initdcl0_innards): Likewise.
(.begin_new_placement): Remove.
(.finish_new_placement): Likewise.
(nonmomentary_expr): Likewise.
(suspend_mom): Likewise.
(condition): Don't suspend_momentary, resume_momentary, or keep
track of need to resume.
(unary_expr): Likewise.
(new_placement): Likewise.
(decl): Likewise.
(structsp): Likewise.
(new_type_id): Likewise.
(maybe_parmlist): Likewise.
(direct_after_type_declaration): Likewise.
(direct_new_declarator): Likewise.
(direct_abstract_declaration): Likewise.
* parse.c: Regenerated.
* pt.c (tsubst_expr): Don't suspend_momentary or resume_momentary.
* semantics.c (begin_new_placement): Remove.
(finish_new_placement): Likewise.
1999-11-05 Martin v. Lwis <loewis@informatik.hu-berlin.de>
* cp-tree.h (VAR_TEMPL_TYPE_OR_FUNCTION_DECL_CHECK): New macro.
......
......@@ -3377,7 +3377,6 @@ void
finish_struct_1 (t)
tree t;
{
int old;
tree fields = TYPE_FIELDS (t);
tree x, last_x, method_vec;
int has_virtual;
......@@ -3427,8 +3426,6 @@ finish_struct_1 (t)
TYPE_SIZE (t) = NULL_TREE;
CLASSTYPE_GOT_SEMICOLON (t) = 0;
old = suspend_momentary ();
/* Install struct as DECL_FIELD_CONTEXT of each field decl.
Also process specified field sizes.
Set DECL_FIELD_SIZE to the specified size, or 0 if none specified.
......@@ -4183,8 +4180,6 @@ finish_struct_1 (t)
undo_template_name_overload (TYPE_IDENTIFIER (t), 1);
#endif
resume_momentary (old);
if (warn_overloaded_virtual)
warn_hidden (t);
......
......@@ -3894,8 +3894,6 @@ extern tree finish_qualified_call_expr PROTO ((tree, tree));
extern tree finish_label_address_expr PROTO((tree));
extern tree finish_unary_op_expr PROTO((enum tree_code, tree));
extern tree finish_id_expr PROTO((tree));
extern int begin_new_placement PROTO((void));
extern tree finish_new_placement PROTO((tree, int));
extern int begin_function_definition PROTO((tree, tree));
extern tree begin_constructor_declarator PROTO((tree, tree));
extern tree finish_declarator PROTO((tree, tree, tree, tree, int));
......
......@@ -9845,13 +9845,6 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
if (size)
{
/* Must suspend_momentary here because the index
type may need to live until the end of the function.
For example, it is used in the declaration of a
variable which requires destructing at the end of
the function; then build_vec_delete will need this
value. */
int yes = suspend_momentary ();
/* Might be a cast. */
if (TREE_CODE (size) == NOP_EXPR
&& TREE_TYPE (size) == TREE_TYPE (TREE_OPERAND (size, 0)))
......@@ -9934,11 +9927,9 @@ grokdeclarator (declarator, declspecs, decl_context, initialized, attrlist)
}
itype = build_index_type (itype);
dont_grok_size:
resume_momentary (yes);
}
dont_grok_size:
type = build_cplus_array_type (type, itype);
ctype = NULL_TREE;
}
......@@ -14055,12 +14046,9 @@ maybe_build_cleanup_1 (decl, auto_delete)
tree type = TREE_TYPE (decl);
if (type != error_mark_node && TYPE_NEEDS_DESTRUCTOR (type))
{
int temp = 0, flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
int flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
tree rval;
if (TREE_CODE (decl) != PARM_DECL)
temp = suspend_momentary ();
if (TREE_CODE (type) == ARRAY_TYPE)
rval = decl;
else
......@@ -14081,9 +14069,6 @@ maybe_build_cleanup_1 (decl, auto_delete)
rval = build_compound_expr (tree_cons (NULL_TREE, rval,
build_expr_list (NULL_TREE, build_vbase_delete (type, decl))));
if (TREE_CODE (decl) != PARM_DECL)
resume_momentary (temp);
return rval;
}
return 0;
......
......@@ -440,12 +440,7 @@ do_pop_exception ()
static void
push_eh_cleanup ()
{
int yes;
yes = suspend_momentary ();
/* All cleanups must last longer than normal. */
finish_decl_cleanup (NULL_TREE, do_pop_exception ());
resume_momentary (yes);
}
/* Build up a call to terminate on the function obstack, for use as an
......@@ -454,10 +449,7 @@ push_eh_cleanup ()
static tree
build_terminate_handler ()
{
int yes = suspend_momentary ();
tree term = build_function_call (terminate_node, NULL_TREE);
resume_momentary (yes);
return term;
return build_function_call (terminate_node, NULL_TREE);
}
/* Initialize the catch parameter DECL. */
......
......@@ -2193,20 +2193,10 @@ build_new_1 (exp)
}
else
{
int susp = 0;
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, 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-
......@@ -2369,9 +2359,6 @@ build_new_1 (exp)
tree cleanup, fn = NULL_TREE;
int flags = LOOKUP_NORMAL | (use_global_new * LOOKUP_GLOBAL);
/* All cleanups must last longer than normal. */
int yes = suspend_momentary ();
/* The Standard is unclear here, but the right thing to do
is to use the same method for finding deallocation
functions that we use for finding allocation functions. */
......@@ -2384,8 +2371,6 @@ build_new_1 (exp)
cleanup = build_op_delete_call (dcode, alloc_node, size, flags, fn);
resume_momentary (yes);
/* Ack! First we allocate the memory. Then we set our sentry
variable to true, and expand a cleanup that deletes the memory
if sentry is true. Then we run the constructor and store the
......@@ -2398,11 +2383,9 @@ build_new_1 (exp)
begin = get_target_expr (boolean_true_node);
sentry = TREE_OPERAND (begin, 0);
yes = suspend_momentary ();
TREE_OPERAND (begin, 2)
= build (COND_EXPR, void_type_node, sentry,
cleanup, void_zero_node);
resume_momentary (yes);
rval = get_target_expr (rval);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -63,7 +63,7 @@ extern int end_of_file;
static const char *cond_stmt_keyword;
static tree empty_parms PROTO((void));
static int parse_decl PROTO((tree, tree, tree, int, tree *));
static void parse_decl PROTO((tree, tree, tree, int, tree *));
/* Nonzero if we have an `extern "C"' acting as an extern specifier. */
int have_extern_spec;
......@@ -199,7 +199,6 @@ empty_parms ()
%type <ttype> reserved_typespecquals
%type <ttype> declmods
%type <ttype> SCSPEC TYPESPEC CV_QUALIFIER maybe_cv_qualifier
%type <itype> initdecls notype_initdecls initdcl /* C++ modification */
%type <ttype> init initlist maybeasm maybe_init defarg defarg1
%type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
%type <ttype> maybe_attribute attributes attribute attribute_list attrib
......@@ -257,10 +256,10 @@ 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 .begin_new_placement
%type <itype> new delete
/* %type <ttype> primary_no_id */
%type <ttype> nonmomentary_expr maybe_parmlist
%type <itype> initdcl0 notype_initdcl0 member_init_list initdcl0_innards
%type <ttype> maybe_parmlist
%type <itype> member_init_list
%type <ttype> template_header template_parm_list template_parm
%type <ttype> template_type_parm template_template_parm
%type <code> template_close_bracket
......@@ -316,7 +315,7 @@ static tree current_enum_type;
extern void yyprint PROTO((FILE *, int, YYSTYPE));
extern tree combine_strings PROTO((tree));
static int
static void
parse_decl (declarator, specs_attrs, attributes, initialized, decl)
tree declarator;
tree specs_attrs;
......@@ -324,8 +323,6 @@ parse_decl (declarator, specs_attrs, attributes, initialized, decl)
int initialized;
tree* decl;
{
int sm;
split_specs_attrs (specs_attrs, &current_declspecs, &prefix_attributes);
if (current_declspecs
&& TREE_CODE (current_declspecs) != TREE_LIST)
......@@ -337,10 +334,8 @@ parse_decl (declarator, specs_attrs, attributes, initialized, decl)
current_declspecs);
used_extern_spec = 1;
}
sm = suspend_momentary ();
*decl = start_decl (declarator, current_declspecs, initialized,
attributes, prefix_attributes);
return sm;
}
void
......@@ -1033,14 +1028,12 @@ condition:
}
}
current_declspecs = $1.t;
$<itype>5 = suspend_momentary ();
$<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1,
$4, /*prefix_attributes*/ NULL_TREE);
}
init
{
cp_finish_decl ($<ttype>6, $7, $4, 1, LOOKUP_ONLYCONVERTING);
resume_momentary ($<itype>5);
$$ = convert_from_reference ($<ttype>6);
if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
cp_error ("definition of array `%#D' in condition", $$);
......@@ -1128,32 +1121,20 @@ unary_expr:
| new new_placement new_type_id new_initializer
{ $$ = build_new ($2, $3.t, $4, $1);
check_for_new_type ("new", $3); }
/* 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
| new '(' type_id ')'
%prec EMPTY
{ $$ = build_new (NULL_TREE, groktypename($4.t),
{ $$ = build_new (NULL_TREE, groktypename($3.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); }
| new new_placement '(' type_id ')' %prec EMPTY
{ $$ = build_new ($2, groktypename($4.t), NULL_TREE, $1);
check_for_new_type ("new", $4); }
| new '(' .begin_new_placement type_id .finish_new_placement
new_initializer
{ $$ = build_new (NULL_TREE, groktypename($4.t), $6, $1);
| new new_placement '(' type_id ')' new_initializer
{ $$ = build_new ($2, groktypename($4.t), $6, $1);
check_for_new_type ("new", $4); }
| new new_placement '(' .begin_new_placement type_id
.finish_new_placement %prec EMPTY
{ $$ = build_new ($2, groktypename($5.t), NULL_TREE, $1);
check_for_new_type ("new", $5); }
| new new_placement '(' .begin_new_placement type_id
.finish_new_placement new_initializer
{ $$ = build_new ($2, groktypename($5.t), $7, $1);
check_for_new_type ("new", $5); }
| delete cast_expr %prec UNARY
{ $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
......@@ -1174,24 +1155,12 @@ unary_expr:
check_for_new_type ("__builtin_va_arg", $5); }
;
/* Note this rule is not suitable for use in new_placement
since it uses NULL_TREE as the argument to
finish_new_placement. This rule serves only to avoid
reduce/reduce conflicts in unary_expr. See the comments
there on the use of begin/finish_new_placement. */
.finish_new_placement:
')'
{ finish_new_placement (NULL_TREE, $<itype>-1); }
.begin_new_placement:
{ $$ = begin_new_placement (); }
new_placement:
'(' .begin_new_placement nonnull_exprlist ')'
{ $$ = finish_new_placement ($3, $2); }
| '{' .begin_new_placement nonnull_exprlist '}'
'(' nonnull_exprlist ')'
{ $$ = $2; }
| '{' nonnull_exprlist '}'
{ cp_pedwarn ("old style placement syntax, use () instead");
$$ = finish_new_placement ($3, $2); }
$$ = $2; }
;
new_initializer:
......@@ -1638,17 +1607,15 @@ object:
decl:
typespec initdecls ';'
{
resume_momentary ($2);
if ($1.t && IS_AGGR_TYPE_CODE (TREE_CODE ($1.t)))
note_got_semicolon ($1.t);
}
| typed_declspecs initdecls ';'
{
resume_momentary ($2);
note_list_got_semicolon ($1.t);
}
| declmods notype_initdecls ';'
{ resume_momentary ($2); }
{}
| typed_declspecs ';'
{
shadow_tag ($1.t);
......@@ -1915,27 +1882,26 @@ initdcl:
we need that reduce so we prefer fn.def1 when appropriate. */
initdcl0_innards:
maybe_attribute '='
{ $<itype>2 = parse_decl ($<ttype>-1, $<ttype>-2,
$1, 1, &$<ttype>$); }
{ parse_decl ($<ttype>-1, $<ttype>-2, $1, 1, &$<ttype>$); }
/* Note how the declaration of the variable is in effect
while its init is parsed! */
init
{ cp_finish_decl ($<ttype>3, $4, $<ttype>0, 1,
LOOKUP_ONLYCONVERTING);
$$ = $<itype>2; }
LOOKUP_ONLYCONVERTING); }
| maybe_attribute
{ tree d;
$$ = parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
parse_decl ($<ttype>-1, $<ttype>-2, $1, 0, &d);
cp_finish_decl (d, NULL_TREE, $<ttype>0, 1, 0); }
;
initdcl0:
declarator maybeasm initdcl0_innards
{ $$ = $3; }
{}
;
notype_initdcl0:
notype_declarator maybeasm initdcl0_innards
{ $$ = $3; }
{}
;
nomods_initdcl0:
......@@ -2097,26 +2063,22 @@ pending_defargs:
structsp:
ENUM identifier '{'
{ $<itype>3 = suspend_momentary ();
$<ttype>$ = current_enum_type;
{ $<ttype>$ = current_enum_type;
current_enum_type = start_enum ($2); }
enumlist_opt '}'
{ TYPE_VALUES (current_enum_type) = $5;
$$.t = finish_enum (current_enum_type);
$$.new_type_flag = 1;
current_enum_type = $<ttype>4;
resume_momentary ((int) $<itype>3);
check_for_missing_semicolon ($$.t); }
| ENUM '{'
{ $<itype>2 = suspend_momentary ();
$<ttype>$ = current_enum_type;
{ $<ttype>$ = current_enum_type;
current_enum_type = start_enum (make_anon_name ()); }
enumlist_opt '}'
{ TYPE_VALUES (current_enum_type) = $4;
$$.t = finish_enum (current_enum_type);
$$.new_type_flag = 1;
current_enum_type = $<ttype>3;
resume_momentary ((int) $<itype>1);
check_for_missing_semicolon ($$.t); }
| ENUM identifier
{ $$.t = xref_tag (enum_type_node, $2, 1);
......@@ -2649,16 +2611,14 @@ 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. For the use of begin_new_placement
here, see the comments in unary_expr above. */
| '(' .begin_new_placement type_id .finish_new_placement
'[' expr ']'
non-constant dimension. */
| '(' type_id ')' '[' expr ']'
{
if (pedantic)
pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
$$.t = build_parse_node (ARRAY_REF, TREE_VALUE ($3.t), $6);
$$.t = build_decl_list (TREE_PURPOSE ($3.t), $$.t);
$$.new_type_flag = $3.new_type_flag;
$$.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;
}
;
......@@ -2681,26 +2641,16 @@ nonempty_cv_qualifiers:
/* These rules must follow the rules for function declarations
and component declarations. That way, longer rules are preferred. */
suspend_mom:
/* empty */
{ $<itype>$ = suspend_momentary (); }
/* An expression which will not live on the momentary obstack. */
nonmomentary_expr:
suspend_mom expr
{ resume_momentary ((int) $<itype>1); $$ = $2; }
;
/* An expression which will not live on the momentary obstack. */
maybe_parmlist:
suspend_mom '(' nonnull_exprlist ')'
{ resume_momentary ((int) $<itype>1); $$ = $3; }
| suspend_mom '(' parmlist ')'
{ resume_momentary ((int) $<itype>1); $$ = $3; }
| suspend_mom LEFT_RIGHT
{ resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
| suspend_mom '(' error ')'
{ resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
'(' nonnull_exprlist ')'
{ $$ = $2; }
| '(' parmlist ')'
{ $$ = $2; }
| LEFT_RIGHT
{ $$ = empty_parms (); }
| '(' error ')'
{ $$ = NULL_TREE; }
;
/* A declarator that is allowed only after an explicit typespec. */
......@@ -2735,7 +2685,7 @@ after_type_declarator:
direct_after_type_declarator:
direct_after_type_declarator maybe_parmlist cv_qualifiers exception_specification_opt %prec '.'
{ $$ = make_call_declarator ($$, $2, $3, $4); }
| direct_after_type_declarator '[' nonmomentary_expr ']'
| direct_after_type_declarator '[' expr ']'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
| direct_after_type_declarator '[' ']'
{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
......@@ -2831,7 +2781,7 @@ complex_direct_notype_declarator:
{ $$ = make_call_declarator ($$, $2, $3, $4); }
| '(' complex_notype_declarator ')'
{ $$ = $2; }
| direct_notype_declarator '[' nonmomentary_expr ']'
| direct_notype_declarator '[' expr ']'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
| direct_notype_declarator '[' ']'
{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
......@@ -3074,7 +3024,7 @@ new_declarator:
direct_new_declarator:
'[' expr ']'
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
| direct_new_declarator '[' nonmomentary_expr ']'
| direct_new_declarator '[' expr ']'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
;
......@@ -3126,7 +3076,7 @@ direct_abstract_declarator:
{ $$ = make_call_declarator ($$, $3, $5, $6); }
| direct_abstract_declarator LEFT_RIGHT cv_qualifiers exception_specification_opt %prec '.'
{ $$ = make_call_declarator ($$, empty_parms (), $3, $4); }
| direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
| direct_abstract_declarator '[' expr ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, $$, $3); }
| direct_abstract_declarator '[' ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
......@@ -3136,7 +3086,7 @@ direct_abstract_declarator:
{ set_quals_and_spec ($$, $2, $3); }
| fcast_or_absdcl cv_qualifiers exception_specification_opt %prec '.'
{ set_quals_and_spec ($$, $2, $3); }
| '[' nonmomentary_expr ']' %prec '.'
| '[' expr ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
| '[' ']' %prec '.'
{ $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
......
......@@ -7097,7 +7097,6 @@ tsubst_expr (t, args, complain, in_decl)
case DECL_STMT:
{
int i = suspend_momentary ();
tree decl;
tree init;
......@@ -7122,7 +7121,6 @@ tsubst_expr (t, args, complain, in_decl)
maybe_push_decl (decl);
cp_finish_decl (decl, init, NULL_TREE, 0, 0);
}
resume_momentary (i);
return decl;
}
......
......@@ -1619,32 +1619,6 @@ finish_id_expr (expr)
return expr;
}
/* Begin a new-placement. */
int
begin_new_placement ()
{
/* The arguments to a placement new might be passed to a
deallocation function, in the event that the allocation throws an
exception. Since we don't expand exception handlers until the
end of a function, we must make sure the arguments stay around
that long. */
return suspend_momentary ();
}
/* Finish a new-placement. The ARGS are the placement arguments. The
COOKIE is the value returned by the previous call to
begin_new_placement. */
tree
finish_new_placement (args, cookie)
tree args;
int cookie;
{
resume_momentary (cookie);
return args;
}
/* Begin a function defniition declared with DECL_SPECS and
DECLARATOR. Returns non-zero if the function-declaration is
legal. */
......
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