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] initialization order patch


I checked in the attached patch.  It fixes some problems caused by
initialization and option processing happening in the wrong order.
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


2003-11-30  Per Bothner  <pbothner@apple.com>

	* c-objc-common.c (init_c_objc_common_once):  Move INIT_STATEMENT_CODES
	to here from init_c_objc_common_eachsrc.

	* c-objc-common.c (init_c_objc_common_eachsrc):  Move call to
	c_decl_processing_eachsrc before cpp_do_macro_callbacks, since
	before does reset_cpp_hashnodes and so would undo latter.
	
	* c-opts.c (finish_options):  Move cpp_find_main_file call out to
	c_common_post_options.
	(c_common_post_options):  Call finish_options only if preprocess-only.
	(init_c_common_eachsrc):  Call finish_options here instead.
	This is because we want to process the command-line after
	reset_cpp_hashnodes, not before.

Index: c-objc-common.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-objc-common.c,v
retrieving revision 1.29.2.5
diff -u -p -r1.29.2.5 c-objc-common.c
--- c-objc-common.c	30 Sep 2003 00:49:04 -0000	1.29.2.5
+++ c-objc-common.c	1 Dec 2003 03:36:52 -0000
@@ -241,6 +241,12 @@ c_warn_unused_global_decl (tree decl)
 void
 init_c_objc_common_once ()
 {
+  static const enum tree_code stmt_codes[] = {
+    c_common_stmt_codes
+  };
+
+  INIT_STATEMENT_CODES (stmt_codes);
+
   if ((server_mode >= 0 && server_mode != 1)
       /* In this case we must write #define and #undef debug information
 	 into the assembler file.  But that hasn't been opened yet.  When
@@ -268,15 +274,9 @@ init_c_objc_common_once ()
 bool
 init_c_objc_common_eachsrc (void)
 {
-  static const enum tree_code stmt_codes[] = {
-    c_common_stmt_codes
-  };
+  init_c_decl_processing_eachsrc ();
 
   cpp_do_macro_callbacks (parse_in, builtins_fragment);
-
-  INIT_STATEMENT_CODES (stmt_codes);
-
-  init_c_decl_processing_eachsrc ();
 
   if (init_c_common_eachsrc () == false)
     return false;
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.79.2.11
diff -u -p -r1.79.2.11 c-opts.c
--- c-opts.c	24 Nov 2003 21:56:13 -0000	1.79.2.11
+++ c-opts.c	1 Dec 2003 03:36:52 -0000
@@ -107,7 +107,7 @@ static void sanitize_cpp_opts (void);
 static void add_prefixed_path (const char *, size_t);
 static void push_command_line_include (void);
 static void cb_file_change (cpp_reader *, const struct line_map *);
-static void finish_options (const char *);
+static void finish_options (void);
 
 #ifndef STDC_0_IN_SYSTEM_HEADERS
 #define STDC_0_IN_SYSTEM_HEADERS 0
@@ -1088,10 +1088,12 @@ c_common_post_options (const char **pfil
   /* kludge - should be moved */
   cpp_post_options (parse_in);
 
-  finish_options (*pfilename);
+  cpp_find_main_file (parse_in, *pfilename);
 
   if (flag_preprocess_only)
     {
+      finish_options ();
+
       preprocess_file (parse_in);
       return true;
     }
@@ -1215,6 +1217,8 @@ init_c_common_once ()
 bool
 init_c_common_eachsrc (void)
 {
+  finish_options ();
+
   input_line = saved_lineno;
 
   return ! flag_preprocess_only;
@@ -1395,14 +1399,10 @@ add_prefixed_path (const char *suffix, s
   add_path (path, chain, 0);
 }
 
-/* Handle -D, -U, -A, -imacros, and the first -include.  
-   TIF is the input file to which we will return after processing all
-   the includes.  */
+/* Handle -D, -U, -A, -imacros, and the first -include.  */
 static void
-finish_options (const char *tif)
+finish_options (void)
 {
-  cpp_find_main_file (parse_in, tif);
-
   if (!cpp_opts->preprocessed)
     {
       size_t i;

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