C++ PATCH for template crash

Mark Mitchell mark@markmitchell.com
Tue Mar 2 23:31:00 GMT 1999


This patch avoids a situation where we would trash the momentary
obstack in pt.c (tsubst_aggr_type):

	  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 ();

If the tsubst_template_arg_vector caused us to start compiling a new
function, we would not call push_cp_function_context, and therefore
not call save_tree_status, and therefore trash our momentary obstack.

Unfortunately, I don't have a small, publicly available test-case.

-- 
Mark Mitchell 			mark@markmitchell.com
Mark Mitchell Consulting	http://www.markmitchell.com

1999-03-02  Mark Mitchell  <mark@markmitchell.com>

	* decl.c (maybe_push_to_top_level): Always call
	push_cp_function_context.
	(pop_from_top_level): Always call pop_cp_function_context.

Index: testsuite/cp/decl.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/decl.c,v
retrieving revision 1.312
diff -c -p -r1.312 decl.c
*** decl.c	1999/02/21 16:38:14	1.312
--- decl.c	1999/03/02 21:40:34
*************** maybe_push_to_top_level (pseudo)
*** 2198,2205 ****
    struct binding_level *b = inner_binding_level;
    tree old_bindings = NULL_TREE;
  
!   if (current_function_decl)
!     push_cp_function_context (NULL_TREE);
  
    if (previous_class_type)
      old_bindings = store_bindings (previous_class_values, old_bindings);
--- 2198,2204 ----
    struct binding_level *b = inner_binding_level;
    tree old_bindings = NULL_TREE;
  
!   push_cp_function_context (NULL_TREE);
  
    if (previous_class_type)
      old_bindings = store_bindings (previous_class_values, old_bindings);
*************** pop_from_top_level ()
*** 2339,2346 ****
  
    free (s);
  
!   if (current_function_decl)
!     pop_cp_function_context (NULL_TREE);
  }
  
  /* Push a definition of struct, union or enum tag "name".
--- 2338,2344 ----
  
    free (s);
  
!   pop_cp_function_context (NULL_TREE);
  }
  
  /* Push a definition of struct, union or enum tag "name".


More information about the Gcc-patches mailing list