public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Per Bothner <per@bothner.com>
To: gcc-patches@gcc.gnu.org
Subject: [cs] initialization order patch
Date: Mon, 01 Dec 2003 04:35:00 -0000	[thread overview]
Message-ID: <3FCAC526.9050608@bothner.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 197 bytes --]

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/



[-- Attachment #2: init-opts.patch --]
[-- Type: text/plain, Size: 3439 bytes --]

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;

                 reply	other threads:[~2003-12-01  4:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3FCAC526.9050608@bothner.com \
    --to=per@bothner.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).