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]

[cs] new restore_fragment macro


I checked in to the compile-server branch the attached patch.
It's a minor cleanup in preparation for the coming gcc/cp patch.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-08-17  Per Bothner  <pbothner@apple.com>

	* c-common.c (restore_fragment):  New function.
	(reset_cpp_hashnodes, cb_enter_fragment):  use it.
	* c-common.h (restore_fragment):  New declaration.
	* c-decl.c (init_c_decl_processing_eachsrc):  Remove call to
	restore_fragment_bindings as it is handled by reset_cpp_hashnodes.

Index: c-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.c,v
retrieving revision 1.438.2.2
diff -u -p -r1.438.2.2 c-common.c
--- c-common.c	15 Aug 2003 18:25:36 -0000	1.438.2.2
+++ c-common.c	17 Aug 2003 16:29:31 -0000
@@ -4165,7 +4165,8 @@ struct c_include_fragment *current_c_fra
 /* Special pseudo-fragment providing the <built-in> declarations. */
 struct cpp_fragment *builtins_fragment;
 
-/* The c_include_frgment corresponding to builtins_fragment. */
+/* The c_include_frgment corresponding to builtins_fragment.
+   Equivalent to C_FRAGMENT (builtins_fragment), but we need this for gc. */
 struct c_include_fragment *builtins_c_fragment;
 
 extern void register_fragment_dependency PARAMS ((struct c_include_fragment*));
@@ -4408,15 +4409,22 @@ reset_cpp_hashnodes ()
   cpp_undef_all (parse_in);
 #endif
   cpp_forall_identifiers (parse_in, lang_clear_identifier, NULL);
-  _cpp_restore_macros (parse_in,
-		       builtins_fragment->macro_notes, builtins_fragment->macro_notes_count);
+  restore_fragment (builtins_fragment);
   /*  parse_in->buffer = NULL;*/
 }
 
+void
+restore_fragment (cpp_fragment *fragment)
+{
+  _cpp_restore_macros (parse_in,
+		       fragment->macro_notes, fragment->macro_notes_count);
+  restore_fragment_bindings (C_FRAGMENT (fragment)->bindings);
+}
+
 /* Called from cpp at the start of a new fragment.
    Check if the fragment has been seen before and we can re-use the
    previously-seen bindings.  If so restore them and return true
-   (so cpp can skip to teh end of the fragment).  Otherwise, sets things
+   (so cpp can skip to the end of the fragment).  Otherwise, sets things
    up so we can remember new bindings as we see them. */
 
 bool
@@ -4461,9 +4469,7 @@ cb_enter_fragment (reader, fragment, nam
 	{
 	  if (! quiet_flag)
 	    fprintf (stderr, "(reusing cached fragment %s:%d)\n", name, line);
-	  restore_fragment_bindings (st->bindings);
-	  _cpp_restore_macros (parse_in,
-			       fragment->macro_notes, fragment->macro_notes_count);
+	  restore_fragment (fragment);
 	}
     }
   else
Index: c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.194.2.3
diff -u -p -r1.194.2.3 c-common.h
--- c-common.h	15 Aug 2003 18:25:36 -0000	1.194.2.3
+++ c-common.h	17 Aug 2003 16:29:32 -0000
@@ -218,6 +218,7 @@ extern GTY(()) struct c_include_fragment
 extern struct cpp_fragment *builtins_fragment;
 extern int currently_nested;
 
+extern void restore_fragment (cpp_fragment *);
 extern void register_decl_dependency (tree);
 extern struct c_include_fragment * alloc_include_fragment (void);
 extern void reset_hashnode (cpp_hashnode*);
Index: c-decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-decl.c,v
retrieving revision 1.417.2.2
diff -u -p -r1.417.2.2 c-decl.c
--- c-decl.c	15 Aug 2003 23:37:52 -0000	1.417.2.2
+++ c-decl.c	17 Aug 2003 16:29:35 -0000
@@ -507,11 +507,10 @@ init_c_decl_processing_eachsrc ()
       current_scope = global_scope;
       if (server_mode != 1)
 	{
-	  reset_cpp_hashnodes ();
 	  current_scope = global_scope;
 	  global_scope->tags = NULL_TREE;
 	  global_scope->names = NULL_TREE;
-	  restore_fragment_bindings (builtins_c_fragment->bindings);
+	  reset_cpp_hashnodes ();
 	}
   }
 

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