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] patches to c-lang.c c-ops.c c-tree.h


I checked in the attached changes to the
compile-server branch.  Again, the branch
will almost certainly not build ...
--
	--Per Bothner
per@bothner.com   http://per.bothner.com/


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

	* c-lang.c (finish_file):  Remove.  Combine with ...
	(c_write_globals):  New function.
	(LANG_HOOKS_WRITE_GLOBALS):  New macro, defined as c_write_globals.
	(LANG_HOOKS_INIT_ONCE):  New definition, as init_c_objc_common_once.
	(LANG_HOOKS_INIT):  Update to renamed init_c_objc_common_eachsrc.
	* c-tree.h:  Add new or rename function declarations.
	* c-opts.c (this_input_filename): Remove variable.
	(c_common_post_options):  Don't canonicalie input filename here.
	Move some stuff to init_c_common_once.
	If only preprocessing, do it now (kludge).
	(init_c_common_once):  New function.
	(c_common_init):  Renamed to init_c_common_eachsrc.
	(c_common_parse_file):  Now parses just a single module,
	rather than loop over modules.
	(finish_options):   Takes no parameters.  Move calls.
	Now called before cpp_read_main_file, so first cpp_child_file is
	LC_ENTER rather than LC_RENAME.  Also do an LC_LEAVE.
	
Index: c-lang.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-lang.c,v
retrieving revision 1.110.2.1
diff -u -p -r1.110.2.1 c-lang.c
--- c-lang.c	12 Aug 2003 23:06:49 -0000	1.110.2.1
+++ c-lang.c	15 Aug 2003 21:46:10 -0000
@@ -35,14 +35,17 @@ Software Foundation, 59 Temple Place - S
 
 static void c_initialize_diagnostics (diagnostic_context *);
 
+static void c_write_globals (void);
 enum c_language_kind c_language = clk_c;
 
 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
 
 #undef LANG_HOOKS_NAME
 #define LANG_HOOKS_NAME "GNU C"
+#undef LANG_HOOKS_INIT_ONCE
+#define LANG_HOOKS_INIT_ONCE init_c_objc_common_once
 #undef LANG_HOOKS_INIT
-#define LANG_HOOKS_INIT c_objc_common_init
+#define LANG_HOOKS_INIT init_c_objc_common_eachsrc
 #undef LANG_HOOKS_FINISH
 #define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
@@ -130,7 +133,7 @@ enum c_language_kind c_language = clk_c;
 #define LANG_HOOKS_TYPE_PROMOTES_TO c_type_promotes_to
 
 #undef LANG_HOOKS_WRITE_GLOBALS
-#define LANG_HOOKS_WRITE_GLOBALS c_write_global_declarations
+#define LANG_HOOKS_WRITE_GLOBALS c_write_globals
 
 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
 
@@ -218,12 +221,12 @@ lookup_objc_ivar (tree id ATTRIBUTE_UNUS
   return 0;
 }
 
-void
-finish_file (void)
+static void
+c_write_globals ()
 {
   c_objc_common_finish_file ();
+  c_write_global_declarations ();
 }
-
 static void
 c_initialize_diagnostics (diagnostic_context *context)
 {
Index: c-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-tree.h,v
retrieving revision 1.124.2.1
diff -u -p -r1.124.2.1 c-tree.h
--- c-tree.h	12 Aug 2003 23:06:50 -0000	1.124.2.1
+++ c-tree.h	15 Aug 2003 21:46:10 -0000
@@ -179,7 +179,8 @@ extern void insert_block (tree);
 extern void set_block (tree);
 extern tree pushdecl (tree);
 
-extern void c_init_decl_processing (void);
+extern void init_c_decl_processing_once (void);
+extern void init_c_decl_processing_eachsrc (void);
 extern void c_dup_lang_specific_decl (tree);
 extern void c_print_identifier (FILE *, tree, int);
 extern tree build_array_declarator (tree, tree, int, int);
@@ -228,7 +229,8 @@ extern void merge_translation_unit_decls
 /* in c-objc-common.c */
 extern int c_disregard_inline_limits (tree);
 extern int c_cannot_inline_tree_fn (tree *);
-extern bool c_objc_common_init (void);
+extern void init_c_objc_common_once (void);
+extern bool init_c_objc_common_eachsrc (void);
 extern int c_missing_noreturn_ok_p (tree);
 extern void c_objc_common_finish_file (void);
 extern int defer_fn (tree);
Index: c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.79.2.2
diff -u -p -r1.79.2.2 c-opts.c
--- c-opts.c	14 Aug 2003 19:41:05 -0000	1.79.2.2
+++ c-opts.c	15 Aug 2003 21:46:10 -0000
@@ -51,9 +51,6 @@ static int saved_lineno;
 /* CPP's options.  */
 static cpp_options *cpp_opts;
 
-/* Input filename.  */
-static const char *this_input_filename;
-
 /* Filename and stream for preprocessed output.  */
 static const char *out_fname;
 static FILE *out_stream;
@@ -108,7 +105,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
@@ -1038,63 +1035,11 @@ c_common_handle_option (size_t scode, co
 bool
 c_common_post_options (const char **pfilename)
 {
-  /* Canonicalize the input and output filenames.  */
-  if (in_fnames == NULL)
-    {
-      in_fnames = xmalloc (sizeof (in_fnames[0]));
-      in_fnames[0] = "";
-    }
-  else if (strcmp (in_fnames[0], "-") == 0)
-    in_fnames[0] = "";
-
+  /* Canonicalize the output filename.  */
   if (out_fname == NULL || !strcmp (out_fname, "-"))
     out_fname = "";
 
-  if (cpp_opts->deps.style == DEPS_NONE)
-    check_deps_environment_vars ();
-
-  handle_deferred_opts ();
-
-  sanitize_cpp_opts ();
-
-  register_include_chains (parse_in, sysroot, iprefix,
-			   std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
-
-  flag_inline_trees = 1;
-
-  /* Use tree inlining if possible.  Function instrumentation is only
-     done in the RTL level, so we disable tree inlining.  */
-  if (! flag_instrument_function_entry_exit)
-    {
-      if (!flag_no_inline)
-	flag_no_inline = 1;
-      if (flag_inline_functions)
-	{
-	  flag_inline_trees = 2;
-	  flag_inline_functions = 0;
-	}
-    }
-
-  /* -Wextra implies -Wsign-compare, but not if explicitly
-      overridden.  */
-  if (warn_sign_compare == -1)
-    warn_sign_compare = extra_warnings;
-
-  /* Special format checking options don't work without -Wformat; warn if
-     they are used.  */
-  if (warn_format_y2k && !warn_format)
-    warning ("-Wformat-y2k ignored without -Wformat");
-  if (warn_format_extra_args && !warn_format)
-    warning ("-Wformat-extra-args ignored without -Wformat");
-  if (warn_format_zero_length && !warn_format)
-    warning ("-Wformat-zero-length ignored without -Wformat");
-  if (warn_format_nonliteral && !warn_format)
-    warning ("-Wformat-nonliteral ignored without -Wformat");
-  if (warn_format_security && !warn_format)
-    warning ("-Wformat-security ignored without -Wformat");
-  if (warn_missing_format_attribute && !warn_format)
-    warning ("-Wmissing-format-attribute ignored without -Wformat");
-
+  /* NULL is passed up to toplev.c and we exit quickly.  */
   if (flag_preprocess_only)
     {
       /* Open the output now.  We must do so even if flag_no_output is
@@ -1111,15 +1056,10 @@ c_common_post_options (const char **pfil
 	  return false;
 	}
 
-      if (num_in_fnames > 1)
-	error ("too many filenames given.  Type %s --help for usage",
-	       progname);
-
       init_pp_output (out_stream);
     }
   else
     {
-      register_cpp_callbacks ();
       init_c_lex ();
 
       /* Yuk.  WTF is this?  I do know ObjC relies on it somewhere.  */
@@ -1127,27 +1067,31 @@ c_common_post_options (const char **pfil
     }
 
   cpp_get_callbacks (parse_in)->file_change = cb_file_change;
+  /* kludge - should be moved */
   cpp_post_options (parse_in);
 
-  /* NOTE: we use in_fname here, not the one supplied.  */
-  *pfilename = cpp_read_main_file (parse_in, in_fnames[0]);
+  *pfilename = cpp_read_main_file (parse_in, *pfilename);
+
+  if (flag_preprocess_only)
+    {
+      finish_options ();
+      preprocess_file (parse_in);
+      return true;
+    }
 
   saved_lineno = input_line;
-  input_line = 0;
 
   /* If an error has occurred in cpplib, note it so we fail
      immediately.  */
   errorcount += cpp_errors (parse_in);
 
-  return flag_preprocess_only;
+  return false;
 }
 
 /* Front end initialization common to C, ObjC and C++.  */
-bool
-c_common_init (void)
+void
+init_c_common_once ()
 {
-  input_line = saved_lineno;
-
   /* Set up preprocessor arithmetic.  Must be done after call to
      c_common_nodes_and_builtins for type nodes to be good.  */
   cpp_opts->precision = TYPE_PRECISION (intmax_type_node);
@@ -1155,23 +1099,85 @@ c_common_init (void)
   cpp_opts->int_precision = TYPE_PRECISION (integer_type_node);
   cpp_opts->wchar_precision = TYPE_PRECISION (wchar_type_node);
   cpp_opts->unsigned_wchar = TREE_UNSIGNED (wchar_type_node);
-  cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
 
+  cpp_opts->bytes_big_endian = BYTES_BIG_ENDIAN;
   /* This can't happen until after wchar_precision and bytes_big_endian
      are known.  */
   cpp_init_iconv (parse_in);
 
-  if (flag_preprocess_only)
+  register_cpp_callbacks ();
+  if (server_mode > 1
+      || server_mode == 0 /* ??? */)
     {
-      finish_options (in_fnames[0]);
-      preprocess_file (parse_in);
-      return false;
+      cpp_get_callbacks (parse_in)->enter_fragment = cb_enter_fragment;
+      cpp_get_callbacks (parse_in)->exit_fragment = cb_exit_fragment;
     }
 
-  /* Has to wait until now so that cpplib has its hash table.  */
   init_pragma ();
 
-  return true;
+  if (cpp_opts->deps.style == DEPS_NONE)
+    check_deps_environment_vars ();
+
+  handle_deferred_opts ();
+
+  sanitize_cpp_opts ();
+
+  register_include_chains (parse_in, sysroot, iprefix,
+			   std_inc, std_cxx_inc && c_dialect_cxx (), verbose);
+
+  flag_inline_trees = 1;
+
+  /* Use tree inlining if possible.  Function instrumentation is only
+     done in the RTL level, so we disable tree inlining.  */
+  if (! flag_instrument_function_entry_exit)
+    {
+      if (!flag_no_inline)
+	flag_no_inline = 1;
+      if (flag_inline_functions)
+	{
+	  flag_inline_trees = 2;
+	  flag_inline_functions = 0;
+	}
+    }
+
+  /* -Wextra implies -Wsign-compare, but not if explicitly
+      overridden.  */
+  if (warn_sign_compare == -1)
+    warn_sign_compare = extra_warnings;
+
+  /* Special format checking options don't work without -Wformat; warn if
+     they are used.  */
+  if (warn_format_y2k && !warn_format)
+    warning ("-Wformat-y2k ignored without -Wformat");
+  if (warn_format_extra_args && !warn_format)
+    warning ("-Wformat-extra-args ignored without -Wformat");
+  if (warn_format_zero_length && !warn_format)
+    warning ("-Wformat-zero-length ignored without -Wformat");
+  if (warn_format_nonliteral && !warn_format)
+    warning ("-Wformat-nonliteral ignored without -Wformat");
+  if (warn_format_security && !warn_format)
+    warning ("-Wformat-security ignored without -Wformat");
+  if (warn_missing_format_attribute && !warn_format)
+    warning ("-Wmissing-format-attribute ignored without -Wformat");
+
+  if (server_mode >= 0)
+    finish_options ();
+#if 0
+  if (flag_preprocess_onl
+      && num_in_fnames > 1)
+    error ("too many filenames given.  Type %s --help for usage",
+	   progname);
+#endif
+
+  pch_init();
+}
+
+bool
+init_c_common_eachsrc (void)
+{
+  input_line = saved_lineno;
+
+  return ! flag_preprocess_only;
 }
 
 /* Initialize the integrated preprocessor after debug output has been
@@ -1179,38 +1185,24 @@ c_common_init (void)
 void
 c_common_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
 {
-  unsigned file_index;
-  
 #if YYDEBUG != 0
   yydebug = set_yydebug;
 #else
   warning ("YYDEBUG not defined");
 #endif
 
-  file_index = 0;
-  
-  do
-    {
-      if (file_index > 0)
-	{
-	  /* Reset the state of the parser.  */
-	  c_reset_state();
+  (*debug_hooks->start_source_file) (input_line, input_filename);
+  /* Kludge - finish_options emits debug stuff, so needs assembler. */
+  if (server_mode < 0)
+    finish_options ();
 
-	  /* Reset cpplib's macros and start a new file.  */
-	  cpp_undef_all (parse_in);
-	  cpp_read_main_file (parse_in, in_fnames[file_index]);
-	}
-
-      finish_options(in_fnames[file_index]);
-      if (file_index == 0)
-	pch_init();
-      c_parse_file ();
-
-      file_index++;
-    } while (file_index < num_in_fnames);
-  
+  c_parse_file ();
   free_parser_stacks ();
-  finish_file ();
+
+  /*
+  fe_file_change (NULL);
+  cpp_change_file (parse_in, LC_LEAVE, NULL);
+  */
 }
 
 /* Common finish hook for the C, ObjC and C++ front ends.  */
@@ -1366,17 +1358,15 @@ 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 ()
 {
   if (!cpp_opts->preprocessed)
     {
       size_t i;
 
-      cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
+      cpp_change_file (parse_in, LC_ENTER, _("<built-in>"));
       cpp_init_builtins (parse_in, flag_hosted);
       c_cpp_builtins (parse_in);
 
@@ -1418,11 +1408,14 @@ finish_options (const char *tif)
 	      && cpp_push_include (parse_in, opt->arg))
 	    cpp_scan_nooutput (parse_in);
 	}
+      cpp_change_file (parse_in, LC_LEAVE, NULL);
     }
 
   include_cursor = 0;
-  this_input_filename = tif;
+#if 0
+  main_input_filename = tif;
   push_command_line_include ();
+#endif
 }
 
 /* Give CPP the next file given by -include, if any.  */
@@ -1443,7 +1436,7 @@ push_command_line_include (void)
   if (include_cursor == deferred_count)
     {
       /* Restore the line map from <command line>.  */
-      cpp_change_file (parse_in, LC_RENAME, this_input_filename);
+      cpp_change_file (parse_in, LC_RENAME, main_input_filename);
       /* -Wunused-macros should only warn about macros defined hereafter.  */
       cpp_opts->warn_unused_macros = warn_unused_macros;
       include_cursor++;

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