From 19c3b3a65910e344623d494561cdb997268ae33e Mon Sep 17 00:00:00 2001 From: mmitchel Date: Thu, 28 Oct 1999 05:10:05 +0000 Subject: [PATCH] * cp-tree.h (make_temp_vec): Remove. (make_scratch_vec): Likewise. * call.c (add_function_candidate): Use make_tree_vec. (add_conv_candidate): Likewise. (build_builtin_candidate): Likewise. (add_template_candidate_real): Likewise. * class.c (resolve_address_of_overloaded_function): Likewise. * decl.c (start_function): Don't fool with the momentary obstack. (finish_function): Likewise. * init.c (expand_direct_vtbls_init): Likewise. (begin_init_stmts): Likewise. (finish_init_stmts): Likewise. * pt.c (add_to_template_args): Use make_tree_vec. (check_explicit_specialization): Likewise. (coerce_template_parms): Likewise. (lookup_template_class): Don't fool with the momentary obstack. (instantiate_class_template): Likewise. (tsubst_template_arg_vector): Use make_tree_vec. (tsubst_aggr_type): Don't fool with the momentary obstack. (tsubst_decl): Likewise. Use make_tree_vec. (try_one_overload): Likewise. (try_class_unification): Don't fool with the momentary obstack. (get_bindings_real): Use make_tree_vec. (set_mangled_name_for_template_decl): Likewise. * rtti.c (synthesize_tinfo_fn): Don't fool with the momentary obstack. * semantics.c (finish_expr_stmt): Likewise. (finish_do_stmt): Likewise. (finish_for_expr): Likewise. (finish_switch_cond): Likewise. (do_pushlevel): Likewise. (do_poplevel): Likewise. * tree.c (make_temp_vec): Remove. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@30225 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/ChangeLog | 33 +++++++++++++++++++++++++ gcc/cp/call.c | 8 +++---- gcc/cp/class.c | 2 +- gcc/cp/cp-tree.h | 2 -- gcc/cp/decl.c | 7 ------ gcc/cp/init.c | 4 ---- gcc/cp/pt.c | 70 ++++++++++++++---------------------------------------- gcc/cp/rtti.c | 7 +----- gcc/cp/semantics.c | 19 +-------------- gcc/cp/tree.c | 14 ----------- 10 files changed, 58 insertions(+), 108 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index d1537a2..6fb4319 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,38 @@ 1999-10-27 Mark Mitchell + * cp-tree.h (make_temp_vec): Remove. + (make_scratch_vec): Likewise. + * call.c (add_function_candidate): Use make_tree_vec. + (add_conv_candidate): Likewise. + (build_builtin_candidate): Likewise. + (add_template_candidate_real): Likewise. + * class.c (resolve_address_of_overloaded_function): Likewise. + * decl.c (start_function): Don't fool with the momentary obstack. + (finish_function): Likewise. + * init.c (expand_direct_vtbls_init): Likewise. + (begin_init_stmts): Likewise. + (finish_init_stmts): Likewise. + * pt.c (add_to_template_args): Use make_tree_vec. + (check_explicit_specialization): Likewise. + (coerce_template_parms): Likewise. + (lookup_template_class): Don't fool with the momentary obstack. + (instantiate_class_template): Likewise. + (tsubst_template_arg_vector): Use make_tree_vec. + (tsubst_aggr_type): Don't fool with the momentary obstack. + (tsubst_decl): Likewise. Use make_tree_vec. + (try_one_overload): Likewise. + (try_class_unification): Don't fool with the momentary obstack. + (get_bindings_real): Use make_tree_vec. + (set_mangled_name_for_template_decl): Likewise. + * rtti.c (synthesize_tinfo_fn): Don't fool with the momentary obstack. + * semantics.c (finish_expr_stmt): Likewise. + (finish_do_stmt): Likewise. + (finish_for_expr): Likewise. + (finish_switch_cond): Likewise. + (do_pushlevel): Likewise. + (do_poplevel): Likewise. + * tree.c (make_temp_vec): Remove. + * dump.c (dequeue_and_dump): Dump HANDLERs and SAVE_EXPRs. Dump CLEANUP_P for a TRY_BLOCK. * ir.texi: Document SAVE_EXPR. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 889f254..38ce371 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1255,7 +1255,7 @@ add_function_candidate (candidates, fn, arglist, flags) } len = list_length (arglist); - convs = make_scratch_vec (len); + convs = make_tree_vec (len); /* 13.3.2 - Viable functions [over.match.viable] First, to be a viable function, a candidate function shall have enough @@ -1372,7 +1372,7 @@ add_conv_candidate (candidates, fn, obj, arglist) tree totype = TREE_TYPE (TREE_TYPE (fn)); tree parmlist = TYPE_ARG_TYPES (TREE_TYPE (totype)); int i, len = list_length (arglist) + 1; - tree convs = make_scratch_vec (len); + tree convs = make_tree_vec (len); tree parmnode = parmlist; tree argnode = arglist; int viable = 1; @@ -1444,7 +1444,7 @@ build_builtin_candidate (candidates, fnname, type1, type2, types[0] = type1; types[1] = type2; - convs = make_scratch_vec (args[2] ? 3 : (args[1] ? 2 : 1)); + convs = make_tree_vec (args[2] ? 3 : (args[1] ? 2 : 1)); for (i = 0; i < 2; ++i) { @@ -2097,7 +2097,7 @@ add_template_candidate_real (candidates, tmpl, explicit_targs, unification_kind_t strict; { int ntparms = DECL_NTPARMS (tmpl); - tree targs = make_scratch_vec (ntparms); + tree targs = make_tree_vec (ntparms); struct z_candidate *cand; int i; tree fn; diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f393a02..612e0ac 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4850,7 +4850,7 @@ resolve_address_of_overloaded_function (target_type, continue; /* Try to do argument deduction. */ - targs = make_scratch_vec (DECL_NTPARMS (fn)); + targs = make_tree_vec (DECL_NTPARMS (fn)); if (fn_type_unification (fn, explicit_targs, targs, target_arg_types, NULL_TREE, DEDUCE_EXACT) != 0) diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index b71c162..7d712dc 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -3969,7 +3969,6 @@ extern tree hack_decl_function_context PROTO((tree)); extern tree decl_namespace_context PROTO((tree)); extern tree lvalue_type PROTO((tree)); extern tree error_type PROTO((tree)); -extern tree make_temp_vec PROTO((int)); extern tree build_ptr_wrapper PROTO((void *)); extern tree build_expr_ptr_wrapper PROTO((void *)); extern tree build_int_wrapper PROTO((int)); @@ -3995,7 +3994,6 @@ extern tree cp_build_qualified_type_real PROTO((tree, int, int)); #define scratchalloc expralloc #define build_scratch_list build_expr_list -#define make_scratch_vec make_temp_vec #define push_scratch_obstack push_expression_obstack /* in typeck.c */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 329c9f9..72818cb 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -13093,10 +13093,6 @@ start_function (declspecs, declarator, attrs, flags) if (! hack_decl_function_context (decl1)) temporary_allocation (); - /* Make sure that we always have a momntary obstack while we're in a - function body. */ - push_momentary (); - ++function_depth; if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl1)) @@ -13676,9 +13672,6 @@ finish_function (lineno, flags) to the FUNCTION_DECL node itself. */ BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl; - /* Undo the call to push_momentary in start_function. */ - pop_momentary (); - /* Save away current state, if appropriate. */ if (!expanding_p && !processing_template_decl) save_function_data (fndecl); diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 5f395f5..d1af4d7 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -105,7 +105,6 @@ expand_direct_vtbls_init (real_binfo, binfo, init_self, can_elide, addr) tree binfos = BINFO_BASETYPES (binfo); int i, n_baselinks = real_binfos ? TREE_VEC_LENGTH (real_binfos) : 0; - push_momentary (); for (i = 0; i < n_baselinks; i++) { tree real_base_binfo = TREE_VEC_ELT (real_binfos, i); @@ -127,7 +126,6 @@ expand_direct_vtbls_init (real_binfo, binfo, init_self, can_elide, addr) tree base_ptr = convert_pointer_to_real (binfo, addr); expand_virtual_init (real_binfo, base_ptr); } - pop_momentary (); } /* 348 - 351 */ @@ -975,7 +973,6 @@ begin_init_stmts (stmt_expr_p, compound_stmt_p) tree *stmt_expr_p; tree *compound_stmt_p; { - push_momentary (); *stmt_expr_p = begin_stmt_expr (); *compound_stmt_p = begin_compound_stmt (/*has_no_scope=*/1); } @@ -988,7 +985,6 @@ finish_init_stmts (stmt_expr, compound_stmt) tree stmt_expr; tree compound_stmt; { - pop_momentary (); finish_compound_stmt (/*has_no_scope=*/1, compound_stmt); stmt_expr = finish_stmt_expr (stmt_expr); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 8ded333..9427314 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -481,7 +481,7 @@ add_to_template_args (args, extra_args) int j; extra_depth = TMPL_ARGS_DEPTH (extra_args); - new_args = make_temp_vec (TMPL_ARGS_DEPTH (args) + extra_depth); + new_args = make_tree_vec (TMPL_ARGS_DEPTH (args) + extra_depth); for (i = 1; i <= TMPL_ARGS_DEPTH (args); ++i) SET_TMPL_ARGS_LEVEL (new_args, i, TMPL_ARGS_LEVEL (args, i)); @@ -1463,7 +1463,7 @@ check_explicit_specialization (declarator, decl, template_count, flags) int i; tree new_targs; - new_targs = make_temp_vec (parm_depth); + new_targs = make_tree_vec (parm_depth); for (i = arg_depth - parm_depth; i < arg_depth; ++i) TREE_VEC_ELT (new_targs, i - (arg_depth - parm_depth)) = TREE_VEC_ELT (targs, i); @@ -3328,7 +3328,7 @@ coerce_template_parms (parms, args, in_decl, return error_mark_node; } - new_inner_args = make_temp_vec (nparms); + new_inner_args = make_tree_vec (nparms); new_args = add_outermost_template_args (args, new_inner_args); for (i = 0; i < nparms; i++) { @@ -3753,10 +3753,6 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) parm_depth = TMPL_PARMS_DEPTH (parmlist); arg_depth = TMPL_ARGS_DEPTH (arglist); - /* We build up the coerced arguments and such on the - momentary_obstack. */ - push_momentary (); - if (arg_depth == 1 && parm_depth > 1) { /* We've been given an incomplete set of template arguments. @@ -3793,7 +3789,7 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) int i; int saved_depth = TMPL_ARGS_DEPTH (arglist); - tree bound_args = make_temp_vec (parm_depth); + tree bound_args = make_tree_vec (parm_depth); for (i = saved_depth, t = DECL_TEMPLATE_PARMS (template); @@ -3874,10 +3870,7 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) } if (found) - { - pop_momentary (); - return found; - } + return found; /* This type is a "partial instantiation" if any of the template arguments still inolve template parameters. Note that we set @@ -3889,7 +3882,6 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) && !PRIMARY_TEMPLATE_P (template) && TREE_CODE (CP_DECL_CONTEXT (template)) == NAMESPACE_DECL) { - pop_momentary (); found = xref_tag_from_type (TREE_TYPE (template), DECL_NAME (template), /*globalize=*/1); @@ -4009,9 +4001,6 @@ lookup_template_class (d1, arglist, in_decl, context, entering_scope) /* We're done with the permanent obstack, now. */ pop_obstacks (); - /* We're also done with the momentary allocation we started - above. */ - pop_momentary (); /* Reset the name of the type, now that CLASSTYPE_TEMPLATE_INFO is set up. */ @@ -4754,12 +4743,6 @@ instantiate_class_template (type) if (TYPE_BEING_DEFINED (type) || TYPE_SIZE (type)) return type; - /* We want to allocate temporary vectors of template arguments and - template argument expressions on the momentary obstack, not on - the expression obstack. Otherwise, all the space allocated in - argument coercion and such is simply lost. */ - push_momentary (); - /* Figure out which template is being instantiated. */ template = most_general_template (CLASSTYPE_TI_TEMPLATE (type)); my_friendly_assert (TREE_CODE (template) == TEMPLATE_DECL, 279); @@ -4787,7 +4770,7 @@ instantiate_class_template (type) Now, the `S' in `f' is the specialization, not an instantiation of the original template. */ - goto end; + return type; /* Determine what specialization of the original template to instantiate. */ @@ -4822,8 +4805,7 @@ instantiate_class_template (type) } } TYPE_BEING_DEFINED (type) = 1; - type = error_mark_node; - goto end; + return error_mark_node; } } @@ -4835,7 +4817,7 @@ instantiate_class_template (type) /* If the template we're instantiating is incomplete, then clearly there's nothing we can do. */ if (TYPE_SIZE (pattern) == NULL_TREE) - goto end; + return type; /* If this is a partial instantiation, don't tsubst anything. We will only use this type for implicit typename, so the actual contents don't @@ -4851,12 +4833,12 @@ instantiate_class_template (type) /* Pretend that the type is complete, so that we will look inside it during name lookup and such. */ TYPE_SIZE (type) = integer_zero_node; - goto end; + return type; } /* If we've recursively instantiated too many templates, stop. */ if (! push_tinst_level (type)) - goto end; + return type; /* Now we're really doing the instantiation. Mark the type as in the process of being defined. */ @@ -5194,9 +5176,6 @@ instantiate_class_template (type) pop_from_top_level (); pop_tinst_level (); - end: - pop_momentary (); - return type; } @@ -5284,7 +5263,7 @@ tsubst_template_arg_vector (t, args, complain) if (!need_new) return t; - t = make_temp_vec (len); + t = make_tree_vec (len); for (i = 0; i < len; i++) TREE_VEC_ELT (t, i) = elts[i]; @@ -5394,13 +5373,11 @@ tsubst_aggr_type (t, args, complain, in_decl, entering_scope) and supposing that we are instantiating f, then our ARGS will be {int, double}, but, when looking up S we only want {double}. */ - push_momentary (); argvec = tsubst_template_arg_vector (TYPE_TI_ARGS (t), args, complain); r = lookup_template_class (t, argvec, in_decl, context, entering_scope); - pop_momentary (); return cp_build_qualified_type_real (r, TYPE_QUALS (t), complain); @@ -5517,7 +5494,6 @@ tsubst_decl (t, args, type, in_decl) : DECL_TI_ARGS (DECL_RESULT (t)); tree full_args; - push_momentary (); full_args = tsubst_template_arg_vector (tmpl_args, args, /*complain=*/1); @@ -5527,7 +5503,6 @@ tsubst_decl (t, args, type, in_decl) my_friendly_assert (full_args != tmpl_args, 0); spec = retrieve_specialization (t, full_args); - pop_momentary (); if (spec != NULL_TREE) { r = spec; @@ -5676,10 +5651,6 @@ tsubst_decl (t, args, type, in_decl) { tree spec; - /* Allocate template arguments on the momentary obstack, - in case we don't need to keep them. */ - push_momentary (); - /* Calculate the most general template of which R is a specialization, and the complete set of arguments used to specialize R. */ @@ -5695,12 +5666,9 @@ tsubst_decl (t, args, type, in_decl) if (spec) { r = spec; - pop_momentary (); break; } - pop_momentary (); - /* Here, we deal with the peculiar case: template struct S { @@ -5733,7 +5701,7 @@ tsubst_decl (t, args, type, in_decl) { int i; - args = make_temp_vec (parms_depth); + args = make_tree_vec (parms_depth); for (i = 0; i < parms_depth; ++i) TREE_VEC_ELT (args, i) = TREE_VEC_ELT (args, i + (args_depth - parms_depth)); @@ -8020,7 +7988,7 @@ try_one_overload (tparms, orig_targs, targs, parm, arg, strict, try to deduce a template parameter for the same argument, even though there isn't really a conflict. */ nargs = TREE_VEC_LENGTH (targs); - tempargs = make_scratch_vec (nargs); + tempargs = make_tree_vec (nargs); if (unify (tparms, tempargs, parm, arg, sub_strict) != 0) return 0; @@ -8106,11 +8074,9 @@ try_class_unification (tparms, targs, parm, arg) because there are two ways to unify base classes of S<0, 1, 2> with S. If we kept the already deduced knowledge, we would reject the possibility I=1. */ - push_momentary (); - copy_of_targs = make_temp_vec (TREE_VEC_LENGTH (targs)); + copy_of_targs = make_tree_vec (TREE_VEC_LENGTH (targs)); i = unify (tparms, copy_of_targs, CLASSTYPE_TI_ARGS (parm), CLASSTYPE_TI_ARGS (arg), UNIFY_ALLOW_NONE); - pop_momentary (); /* If unification failed, we're done. */ if (i != 0) @@ -8834,7 +8800,7 @@ get_bindings_real (fn, decl, explicit_args, check_rettype) int check_rettype; { int ntparms = DECL_NTPARMS (fn); - tree targs = make_scratch_vec (ntparms); + tree targs = make_tree_vec (ntparms); tree decl_type; tree decl_arg_types; int i; @@ -8934,7 +8900,7 @@ get_class_bindings (tparms, parms, args) tree tparms, parms, args; { int i, ntparms = TREE_VEC_LENGTH (tparms); - tree vec = make_temp_vec (ntparms); + tree vec = make_tree_vec (ntparms); args = innermost_args (args); @@ -9969,13 +9935,13 @@ set_mangled_name_for_template_decl (decl) /* Replace the innermost level of the TARGS with NULL_TREEs to let tsubst know not to subsitute for those parameters. */ - partial_args = make_temp_vec (TREE_VEC_LENGTH (targs)); + partial_args = make_tree_vec (TREE_VEC_LENGTH (targs)); for (i = 1; i < TMPL_ARGS_DEPTH (targs); ++i) SET_TMPL_ARGS_LEVEL (partial_args, i, TMPL_ARGS_LEVEL (targs, i)); SET_TMPL_ARGS_LEVEL (partial_args, TMPL_ARGS_DEPTH (targs), - make_temp_vec (DECL_NTPARMS (tmpl))); + make_tree_vec (DECL_NTPARMS (tmpl))); /* Now, do the (partial) substitution to figure out the appropriate function type. */ diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index f5eb893..2580eaa 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -1137,11 +1137,8 @@ synthesize_tinfo_fn (fndecl) compound_stmt = begin_compound_stmt (/*has_no_scope=*/0); /* For convenience, we save away the address of the static - variable. Since we will process expression-statements between - here and the end of the function, we must call push_momentary to - keep ADDR from being overwritten. */ + variable. */ addr = decay_conversion (tdecl); - push_momentary (); /* If the first word of the array (the vtable) is non-zero, we've already initialized the object, so don't do it again. */ @@ -1193,8 +1190,6 @@ synthesize_tinfo_fn (fndecl) tmp = cp_convert (build_pointer_type (type_info_type_node), addr); tmp = build_indirect_ref (tmp, 0); finish_return_stmt (tmp); - /* Undo the call to push_momentary above. */ - pop_momentary (); /* Finish the function body. */ finish_compound_stmt (/*has_no_scope=*/0, compound_stmt); expand_body (finish_function (lineno, 0)); diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d015719..de6cd08 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -144,10 +144,7 @@ finish_expr_stmt (expr) cplus_expand_expr_stmt (expr); if (stmts_are_full_exprs_p) - { - expand_end_target_temps (); - clear_momentary (); - } + expand_end_target_temps (); } } @@ -368,7 +365,6 @@ finish_do_stmt (cond, do_stmt) expand_end_loop (); } - clear_momentary (); finish_stmt (); } @@ -503,10 +499,6 @@ finish_for_expr (expr, for_stmt) { if (building_stmt_tree ()) FOR_EXPR (for_stmt) = expr; - - /* Don't let the tree nodes for EXPR be discarded - by clear_momentary during the parsing of the next stmt. */ - push_momentary (); } /* Finish the body of a for-statement, which may be given by @@ -532,8 +524,6 @@ finish_for_stmt (expr, for_stmt) expand_end_loop (); } - pop_momentary (); - if (flag_new_for_scope > 0) do_poplevel (); @@ -605,10 +595,6 @@ finish_switch_cond (cond, switch_stmt) c_expand_start_case (boolean_false_node); push_switch (); - - /* Don't let the tree nodes for COND be discarded by - clear_momentary during the parsing of the next stmt. */ - push_momentary (); } /* Finish the body of a switch-statement, which may be given by @@ -623,7 +609,6 @@ finish_switch_stmt (cond, switch_stmt) RECHAIN_STMTS (switch_stmt, SWITCH_BODY (switch_stmt)); else expand_end_case (cond); - pop_momentary (); pop_switch (); do_poplevel (); finish_stmt (); @@ -1295,7 +1280,6 @@ do_pushlevel () emit_line_note (input_filename, lineno); clear_last_expr (); } - push_momentary (); if (stmts_are_full_exprs_p) { pushlevel (0); @@ -1333,7 +1317,6 @@ do_poplevel () t = poplevel (kept_level_p (), 1, 0); } - pop_momentary (); return t; } diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0b5f843..0dbc539 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2517,20 +2517,6 @@ cp_tree_equal (t1, t2) return -1; } -/* Similar to make_tree_vec, but build on the momentary_obstack. - Thus, these vectors are really and truly temporary. */ - -tree -make_temp_vec (len) - int len; -{ - register tree node; - push_expression_obstack (); - node = make_tree_vec (len); - pop_obstacks (); - return node; -} - /* Build a wrapper around some pointer PTR so we can use it as a tree. */ tree -- 2.7.4