This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

C++ PATCH: Avoid ggc_push_context


This patch revmoes the ggc_push_context calls I added a couple of days
ago, since those functions are not supposed to be used.  (I'll be
checking in a follow-up patch for mainline to remove the functions,
shortly, to avoid any similar problems in future.)

Tested on x86_64-unknown-linux-gnu, applied to the mainline and to the
4.0 branch.  

--
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com

2005-09-03  Mark Mitchell  <mark@codesourcery.com>

	PR c++/21687
	* semantics.c (expand_or_defer_fn): Do not call ggc_collect when
	finishing processing for a template function in a local class.
	Revert:
	2005-09-02  Mark Mitchell  <mark@codesourcery.com>
	* parser.c (cp_parser_class_specifier): Push/pop GC contexts
	around functions in local classes.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.354
diff -c -5 -p -r1.354 parser.c
*** cp/parser.c	2 Sep 2005 18:28:57 -0000	1.354
--- cp/parser.c	3 Sep 2005 18:16:16 -0000
*************** cp_parser_class_specifier (cp_parser* pa
*** 12671,12683 ****
      {
        tree queue_entry;
        tree fn;
        tree class_type = NULL_TREE;
        tree pushed_scope = NULL_TREE;
-       /* True if we have called ggc_push_context, and therefore need
- 	 to make a matching call to ggc_pop_context.  */
-       bool need_ggc_pop_context;
   
        /* In a first pass, parse default arguments to the functions.
  	 Then, in a second pass, parse the bodies of the functions.
  	 This two-phased approach handles cases like:
  
--- 12671,12680 ----
*************** cp_parser_class_specifier (cp_parser* pa
*** 12710,12744 ****
  	  /* Remove any template parameters from the symbol table.  */
  	  maybe_end_member_template_processing ();
  	}
        if (pushed_scope)
  	pop_scope (pushed_scope);
-       need_ggc_pop_context = false;
        /* Now parse the body of the functions.  */
        for (TREE_VALUE (parser->unparsed_functions_queues)
  	     = nreverse (TREE_VALUE (parser->unparsed_functions_queues));
  	   (queue_entry = TREE_VALUE (parser->unparsed_functions_queues));
  	   TREE_VALUE (parser->unparsed_functions_queues)
  	     = TREE_CHAIN (TREE_VALUE (parser->unparsed_functions_queues)))
  	{
  	  /* Figure out which function we need to process.  */
  	  fn = TREE_VALUE (queue_entry);
- 	  /* We call ggc_collect after processing a function body in
- 	     order to clean up garbage generated.  If we're processing
- 	     a local class, however, then we must not clean up stuff
- 	     from the function containing the class, so we have to
- 	     push a new garbage-collection context.  */
- 	  if (function_depth && !need_ggc_pop_context)
- 	    {
- 	      need_ggc_pop_context = true;
- 	      ggc_push_context ();
- 	    }
  	  /* Parse the function.  */
  	  cp_parser_late_parsing_for_member (parser, fn);
  	}
-       if (need_ggc_pop_context)
- 	ggc_pop_context ();
      }
  
    /* Put back any saved access checks.  */
    pop_deferring_access_checks ();
  
--- 12707,12728 ----
Index: cp/semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.483
diff -c -5 -p -r1.483 semantics.c
*** cp/semantics.c	31 Aug 2005 08:46:34 -0000	1.483
--- cp/semantics.c	3 Sep 2005 18:16:18 -0000
*************** expand_or_defer_fn (tree fn)
*** 3042,3053 ****
    if (processing_template_decl)
      {
        /* Normally, collection only occurs in rest_of_compilation.  So,
  	 if we don't collect here, we never collect junk generated
  	 during the processing of templates until we hit a
! 	 non-template function.  */
!       ggc_collect ();
        return;
      }
  
    /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs.  */
    walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),
--- 3042,3056 ----
    if (processing_template_decl)
      {
        /* Normally, collection only occurs in rest_of_compilation.  So,
  	 if we don't collect here, we never collect junk generated
  	 during the processing of templates until we hit a
! 	 non-template function.  It's not safe to do this inside a
! 	 nested class, though, as the parser may have local state that
! 	 is not a GC root.  */
!       if (!function_depth)
! 	ggc_collect ();
        return;
      }
  
    /* Replace AGGR_INIT_EXPRs with appropriate CALL_EXPRs.  */
    walk_tree_without_duplicates (&DECL_SAVED_TREE (fn),


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]