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]

Remove 2 lang hooks, cleanup initialization of toplev.c


This patch removes two langhooks that are not part of langhooks.h -
init_parse() and init_decl_processing().  They are folded into the
"init" langhook from langhooks.h.  It also completely reorganizes
initialization in toplev.c; breaking it down to a few logical areas
like parsing options, language-independent initialization and
language-dependent initialization.  There will be at least one
follow-up to this, for cleanup and to document exactly what the
initialization language hooks can assume, and what they are expected
to initialize.

At the same time this fixes PR c/4053, the debug init / CPP init
chicken and egg problem.  We now get the debug info correct if
compiling a preprocessed file; this required some reorganization
of initialization in cpplib too.

The toplev.c changes are very similar to what rth OK-ed a couple of
days ago; I didn't apply them because things had changed in CVS and my
local tree and I couldn't get that patch to bootstrap again.

This has bootstrapped x86 Linux for c, objc, c++, java and f77 without
regressions.  OK to commit?

Neil.

	PR c/4053
	* c-common.c: Include c-lex.h.
	(c_common_lang_init): Change prototype.  Call init_c_lex and
	init_pragma from here.
	* c-common.h (c_common_lang_init): Change prototype.
	* c-decl.c (init_decl_processing): Rename.  Call c_parse_init.
	* c-lang.c (c_init): Change prototype.  Update.
	(c_init_options): Update.
	* c-lex.c (cpp_filename): Remove.
	(init_c_lex): Update.  Read the main file, and get the original
	file name.
	(yyparse): Finish the command line options.
	* c-parse.in (c_parse_init): Call init_reswords here.
	(init_parse): Remove.
	* c-tree.h (c_init_decl_processing): New.
	* cpphash.c (_cpp_init_hashtable): After initializing the hash
	table, populate it.
	* cppinit.c (read_original_filename, cpp_finish_options): New.
	(cpp_create_reader): New prototype. Defer hash table initialization.
	(cpp_start_read): Rename cpp_read_main_file.  Initialize the
	hash table.  Get the original filename.
	* cpplib.h (cpp_create_reader): Update.
	(cpp_start_read): Remove.
	(cpp_read_main_file, cpp_finish_options): New.
	* cppmain.c (main, do_preprocessing): Update.
	* langhooks.h (struct langhooks): Update init prototype.
	* toplev.c (general_init, parse_options_and_default_flags,
	process_options, lang_indpendent_init, lang_dependent_init,
	init_asm_output): New; perform the bulk of initialization.
	(compile_file): Move most of initialization to above functions.
	(debug_hooks): Initialize statically.
	(set_Wunused): Relocate.
	(toplev_main): Move most of initialization to other init functions.
	Have a clear logic flow.
	* tree.h (init_parse, init_decl_processing): Remove.
ada:
	* misc.c (gnat_init): Change prototype.  Include the
	functionality of the old init_parse and init_decl_processing.
	(gnat_init_decl_processing): New prototype.
	(init_parse): Remove.
	* utils.c (init_decl_processing): Rename gnat_init_decl_processing.
cp:	* cp-tree.h (init_reswords, cxx_init_decl_processing): New.
	(cxx_init): Update prototype.
	* decl.c (init_decl_processing): Rename.  Move null node init
	to its creation time.
	* lex.c (cxx_init_options): Update.
	(cxx_init): Combine with old init_parse; also call
	cxx_init_decl_processing.
f:	* com.c (ffecom_init_decl_processing): Renamed from
	init_decl_processing.
	(init_parse): Move contents to ffe_init.
	(ffe_init): Update prototype.
java:	* decl.c (init_decl_processing): Rename java_init_decl_processing.
	* java-tree.h: New prototype.
	* lang.c (java_init): Update prototype.  Combine with old init_parse.
objc:	* objc-act.c (objc_init): Update prototype, combine with old
	init_parse.
	(objc_init_options): Update.

============================================================
Index: gcc/c-common.c
--- gcc/c-common.c	2001/11/06 12:39:26	1.271
+++ gcc/c-common.c	2001/11/12 10:37:37
@@ -32,6 +32,7 @@ Software Foundation, 59 Temple Place - S
 #include "c-common.h"
 #include "tm_p.h"
 #include "obstack.h"
+#include "c-lex.h"
 #include "cpplib.h"
 #include "target.h"
 cpp_reader *parse_in;		/* Declared in c-lex.h.  */
@@ -3809,9 +3810,14 @@ static bool c_attrs_initialized = false;
 static void c_init_attributes PARAMS ((void));
 
 /* Do the parts of lang_init common to C and C++.  */
-void
-c_common_lang_init ()
+const char *
+c_common_lang_init (filename)
+     const char *filename;
 {
+  filename = init_c_lex (filename);
+
+  init_pragma ();
+
   /* If still "unspecified", make it match -fbounded-pointers.  */
   if (flag_bounds_check < 0)
     flag_bounds_check = flag_bounded_pointers;
@@ -3831,6 +3837,8 @@ c_common_lang_init ()
 
   if (!c_attrs_initialized)
     c_init_attributes ();
+
+  return filename;
 }
 
 static void
============================================================
Index: gcc/c-common.h
--- gcc/c-common.h	2001/10/29 23:01:44	1.95
+++ gcc/c-common.h	2001/11/12 10:37:39
@@ -540,7 +540,7 @@ extern void c_common_nodes_and_builtins	
 
 extern tree build_va_arg			PARAMS ((tree, tree));
 
-extern void c_common_lang_init			PARAMS ((void));
+extern const char *c_common_lang_init		PARAMS ((const char *));
 extern HOST_WIDE_INT c_common_get_alias_set	PARAMS ((tree));
 extern bool c_promoting_integer_type_p		PARAMS ((tree));
 extern int self_promoting_args_p		PARAMS ((tree));
============================================================
Index: gcc/c-decl.c
--- gcc/c-decl.c	2001/11/12 00:02:35	1.265
+++ gcc/c-decl.c	2001/11/12 10:37:57
@@ -2977,10 +2977,13 @@ mark_binding_level (arg)
    Make definitions for built-in primitive functions.  */
 
 void
-init_decl_processing ()
+c_init_decl_processing ()
 {
   tree endlink;
   tree ptr_ftype_void, ptr_ftype_ptr;
+
+  /* Adds some ggc roots, and reserved words for c-parse.in.  */
+  c_parse_init ();
 
   current_function_decl = NULL;
   named_labels = NULL;
============================================================
Index: gcc/c-lang.c
--- gcc/c-lang.c	2001/11/12 00:02:35	1.62
+++ gcc/c-lang.c	2001/11/12 10:37:58
@@ -44,7 +44,7 @@ Software Foundation, 59 Temple Place - S
 
 static int c_tree_printer PARAMS ((output_buffer *));
 static int c_missing_noreturn_ok_p PARAMS ((tree));
-static void c_init PARAMS ((void));
+static const char *c_init PARAMS ((const char *));
 static void c_init_options PARAMS ((void));
 static void c_post_options PARAMS ((void));
 static int c_disregard_inline_limits PARAMS ((tree));
@@ -108,16 +108,21 @@ c_post_options ()
 static void
 c_init_options ()
 {
-  parse_in = cpp_create_reader (ident_hash, CLK_GNUC89);
+  parse_in = cpp_create_reader (CLK_GNUC89);
 
   /* Mark as "unspecified".  */
   flag_bounds_check = -1;
 }
 
-static void
-c_init ()
+static const char *
+c_init (filename)
+     const char *filename;
 {
-  c_common_lang_init ();
+  c_init_decl_processing ();
+
+  filename = c_common_lang_init (filename);
+
+  add_c_tree_codes ();
 
   /* If still unspecified, make it match -std=c99
      (allowing for -pedantic-errors).  */
@@ -138,10 +143,10 @@ c_init ()
   lang_expand_decl_stmt = &c_expand_decl_stmt;
   lang_missing_noreturn_ok_p = &c_missing_noreturn_ok_p;
 
-  c_parse_init ();
-
   VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
   ggc_add_tree_varray_root (&deferred_fns, 1);
+
+  return filename;
 }
 
 /* Used by c-lex.c, but only for objc.  */
============================================================
Index: gcc/c-lex.c
--- gcc/c-lex.c	2001/10/30 12:14:27	1.154
+++ gcc/c-lex.c	2001/11/12 10:38:00
@@ -54,9 +54,6 @@ Software Foundation, 59 Temple Place - S
 #define GET_ENVIRONMENT(ENV_VALUE,ENV_NAME) ((ENV_VALUE) = getenv (ENV_NAME))
 #endif
 
-/* The input filename as understood by CPP, where "" represents stdin.  */
-static const char *cpp_filename;
-
 /* The current line map.  */
 static const struct line_map *map;
 
@@ -109,7 +106,7 @@ init_c_lex (filename)
   struct cpp_callbacks *cb;
   struct c_fileinfo *toplevel;
 
-  /* Set up filename timing.  Must happen before cpp_start_read.  */
+  /* Set up filename timing.  Must happen before cpp_read_main_file.  */
   file_info_tree = splay_tree_new ((splay_tree_compare_fn)strcmp,
 				   0,
 				   (splay_tree_delete_value_fn)free);
@@ -142,16 +139,13 @@ init_c_lex (filename)
       cb->undef = cb_undef;
     }
 
-
-  if (filename == 0 || !strcmp (filename, "-"))
-    filename = "stdin", cpp_filename = "";
-  else
-    cpp_filename = filename;
-
   /* Start it at 0.  */
   lineno = 0;
 
-  return filename;
+  if (filename == NULL)
+    filename = "";
+
+  return cpp_read_main_file (parse_in, filename, ident_hash);
 }
 
 /* A thin wrapper around the real parser that initializes the 
@@ -160,8 +154,7 @@ init_c_lex (filename)
 int
 yyparse()
 {
-  if (! cpp_start_read (parse_in, cpp_filename))
-    return 1;			/* cpplib has emitted an error.  */
+  cpp_finish_options (parse_in);
 
   return yyparse_1();
 }
============================================================
Index: gcc/c-parse.in
--- gcc/c-parse.in	2001/11/09 23:30:20	1.112
+++ gcc/c-parse.in	2001/11/12 10:38:08
@@ -304,6 +304,8 @@ static void init_reswords PARAMS ((void)
 void
 c_parse_init ()
 {
+  init_reswords ();
+
   ggc_add_tree_root (&declspec_stack, 1);
   ggc_add_tree_root (&current_declspecs, 1);
   ggc_add_tree_root (&prefix_attributes, 1);
@@ -3526,17 +3528,6 @@ init_reswords ()
       C_IS_RESERVED_WORD (id) = 1;
       ridpointers [(int) reswords[i].rid] = id;
     }
-}
-
-const char *
-init_parse (filename)
-     const char *filename;
-{
-  add_c_tree_codes ();
-  init_reswords ();
-  init_pragma ();
-
-  return init_c_lex (filename);
 }
 
 void
============================================================
Index: gcc/c-tree.h
--- gcc/c-tree.h	2001/11/12 00:02:35	1.74
+++ gcc/c-tree.h	2001/11/12 10:38:09
@@ -164,6 +164,7 @@ extern int yyparse_1				PARAMS ((void));
 extern void gen_aux_info_record                 PARAMS ((tree, int, int, int));
 
 /* in c-decl.c */
+extern void c_init_decl_processing		PARAMS ((void));
 extern void c_print_identifier			PARAMS ((FILE *, tree, int));
 extern tree build_array_declarator              PARAMS ((tree, tree, int, int));
 extern tree build_enumerator                    PARAMS ((tree, tree));
============================================================
Index: gcc/cpphash.c
--- gcc/cpphash.c	2001/08/11 12:37:17	1.114
+++ gcc/cpphash.c	2001/11/12 10:38:09
@@ -53,6 +53,8 @@ _cpp_init_hashtable (pfile, table)
      cpp_reader *pfile;
      hash_table *table;
 {
+  struct spec_nodes *s;
+
   if (table == NULL)
     {
       pfile->our_hashtable = 1;
@@ -63,6 +65,20 @@ _cpp_init_hashtable (pfile, table)
 
   table->pfile = pfile;
   pfile->hash_table = table;
+
+  /* Now we can initialize things that use the hash table.  */
+  _cpp_init_directives (pfile);
+  _cpp_init_internal_pragmas (pfile);
+
+  s = &pfile->spec_nodes;
+  s->n_L                = cpp_lookup (pfile, DSC("L"));
+  s->n_defined		= cpp_lookup (pfile, DSC("defined"));
+  s->n_true		= cpp_lookup (pfile, DSC("true"));
+  s->n_false		= cpp_lookup (pfile, DSC("false"));
+  s->n__STRICT_ANSI__   = cpp_lookup (pfile, DSC("__STRICT_ANSI__"));
+  s->n__CHAR_UNSIGNED__ = cpp_lookup (pfile, DSC("__CHAR_UNSIGNED__"));
+  s->n__VA_ARGS__       = cpp_lookup (pfile, DSC("__VA_ARGS__"));
+  s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC;
 }
 
 /* Tear down the identifier hash table.  */
============================================================
Index: gcc/cppinit.c
--- gcc/cppinit.c	2001/10/02 12:57:23	1.188
+++ gcc/cppinit.c	2001/11/12 10:38:14
@@ -63,7 +63,7 @@ struct pending_option
 };
 
 /* The `pending' structure accumulates all the options that are not
-   actually processed until we hit cpp_start_read.  It consists of
+   actually processed until we hit cpp_read_main_file.  It consists of
    several lists, one for each type of option.  We keep both head and
    tail pointers for quick insertion.  */
 struct cpp_pending
@@ -111,6 +111,7 @@ static void free_chain			PARAMS ((struct
 static void set_lang			PARAMS ((cpp_reader *, enum c_lang));
 static void init_dependency_output	PARAMS ((cpp_reader *));
 static void init_standard_includes	PARAMS ((cpp_reader *));
+static void read_original_filename	PARAMS ((cpp_reader *));
 static void new_pending_directive	PARAMS ((struct cpp_pending *,
 						 const char *,
 						 cl_directive_handler));
@@ -476,11 +477,9 @@ init_library ()
 
 /* Initialize a cpp_reader structure.  */
 cpp_reader *
-cpp_create_reader (table, lang)
-     hash_table *table;
+cpp_create_reader (lang)
      enum c_lang lang;
 {
-  struct spec_nodes *s;
   cpp_reader *pfile;
 
   /* Initialise this instance of the library if it hasn't been already.  */
@@ -534,23 +533,7 @@ cpp_create_reader (table, lang)
   /* Initialise the buffer obstack.  */
   gcc_obstack_init (&pfile->buffer_ob);
 
-  /* Initialise the hashtable.  */
-  _cpp_init_hashtable (pfile, table);
-
-  _cpp_init_directives (pfile);
   _cpp_init_includes (pfile);
-  _cpp_init_internal_pragmas (pfile);
-
-  /* Initialize the special nodes.  */
-  s = &pfile->spec_nodes;
-  s->n_L                = cpp_lookup (pfile, DSC("L"));
-  s->n_defined		= cpp_lookup (pfile, DSC("defined"));
-  s->n_true		= cpp_lookup (pfile, DSC("true"));
-  s->n_false		= cpp_lookup (pfile, DSC("false"));
-  s->n__STRICT_ANSI__   = cpp_lookup (pfile, DSC("__STRICT_ANSI__"));
-  s->n__CHAR_UNSIGNED__ = cpp_lookup (pfile, DSC("__CHAR_UNSIGNED__"));
-  s->n__VA_ARGS__       = cpp_lookup (pfile, DSC("__VA_ARGS__"));
-  s->n__VA_ARGS__->flags |= NODE_DIAGNOSTIC;
 
   return pfile;
 }
@@ -704,7 +687,7 @@ static const struct builtin builtin_arra
 #define builtin_array_end \
  builtin_array + sizeof(builtin_array)/sizeof(struct builtin)
 
-/* Subroutine of cpp_start_read; reads the builtins table above and
+/* Subroutine of cpp_read_main_file; reads the builtins table above and
    enters the macros into the hash table.  */
 static void
 init_builtins (pfile)
@@ -919,11 +902,17 @@ free_chain (head)
 /* This is called after options have been processed.  Setup for
    processing input from the file named FNAME, or stdin if it is the
    empty string.  Return 1 on success, 0 on failure.  */
-int
-cpp_start_read (pfile, fname)
+const char *
+cpp_read_main_file (pfile, fname, table)
      cpp_reader *pfile;
      const char *fname;
+     hash_table *table;
 {
+  /* The front ends don't set up the hash table until they have
+     finished processing the command line options, so initializing the
+     hashtable is deferred until now.  */
+  _cpp_init_hashtable (pfile, table);
+
   /* Set up the include search path now.  */
   if (! CPP_OPTION (pfile, no_standard_includes))
     init_standard_includes (pfile);
@@ -948,16 +937,60 @@ cpp_start_read (pfile, fname)
     /* Set the default target (if there is none already).  */
     deps_add_default_target (pfile->deps, fname);
 
-  /* Open the main input file.  This must be done early, so we have a
-     buffer to stand on.  */
+  /* Open the main input file.  */
   if (!_cpp_read_file (pfile, fname))
-    return 0;
+    return NULL;
 
   /* Set this after cpp_post_options so the client can change the
      option if it wishes, and after stacking the main file so we don't
      trace the main file.  */
   pfile->line_maps.trace_includes = CPP_OPTION (pfile, print_include_names);
 
+  /* For foo.i, read the original filename foo.c now, for the benefit
+     of the front ends.  */
+  if (CPP_OPTION (pfile, preprocessed))
+    read_original_filename (pfile);
+
+  return pfile->map->to_file;
+}
+
+/* For preprocessed files, if the first tokens are of the form # NUM.
+   handle the directive so we know the original file name.  This will
+   generate file_change callbacks, which the front ends must handle
+   appropriately given their state of initialization.  */
+static void
+read_original_filename (pfile)
+     cpp_reader *pfile;
+{
+  const cpp_token *token, *token1;
+
+  /* Lex ahead; if the first tokens are of the form # NUM, then
+     process the directive, otherwise back up.  */
+  token = _cpp_lex_direct (pfile);
+  if (token->type == CPP_HASH)
+    {
+      token1 = _cpp_lex_direct (pfile);
+      _cpp_backup_tokens (pfile, 1);
+
+      /* If it's a #line directive, handle it.  */
+      if (token1->type == CPP_NUMBER)
+	{
+	  _cpp_handle_directive (pfile, token->flags & PREV_WHITE);
+	  return;
+	}
+    }
+
+  /* Backup as if nothing happened.  */
+  _cpp_backup_tokens (pfile, 1);
+}
+
+/* Handle pending command line options: -D, -U, -A, -imacros and
+   -include.  This should be called after debugging has been properly
+   set up in the front ends.  */
+void
+cpp_finish_options (pfile)
+     cpp_reader *pfile;
+{
   /* Install builtins and process command line macros etc. in the order
      they appeared, but only if not already preprocessed.  */
   if (! CPP_OPTION (pfile, preprocessed))
@@ -986,8 +1019,6 @@ cpp_start_read (pfile, fname)
 
   free_chain (CPP_OPTION (pfile, pending)->directive_head);
   _cpp_push_next_buffer (pfile);
-
-  return 1;
 }
 
 /* Called to push the next buffer on the stack given by -include.  If
============================================================
Index: gcc/cpplib.h
--- gcc/cpplib.h	2001/10/14 17:43:58	1.197
+++ gcc/cpplib.h	2001/11/12 10:38:15
@@ -451,16 +451,8 @@ struct cpp_hashnode
   } value;
 };
 
-/* Call this first to get a handle to pass to other functions.  If you
-   want cpplib to manage its own hashtable, pass in a NULL pointer.
-   Or you can pass in an initialised hash table that cpplib will use;
-   this technique is used by the C front ends.  */
-extern cpp_reader *cpp_create_reader PARAMS ((struct ht *,
-					      enum c_lang));
-
-/* Call this to release the handle.  Any use of the handle after this
-   function returns is invalid.  Returns cpp_errors (pfile).  */
-extern int cpp_destroy PARAMS ((cpp_reader *));
+/* Call this first to get a handle to pass to other functions.  */
+extern cpp_reader *cpp_create_reader PARAMS ((enum c_lang));
 
 /* Call these to get pointers to the options and callback structures
    for a given reader.  These pointers are good until you call
@@ -476,13 +468,39 @@ extern void cpp_set_callbacks PARAMS ((c
    return value is the number of arguments used.  If
    cpp_handle_options returns without using all arguments, it couldn't
    understand the next switch.  When there are no switches left, you
-   must call cpp_post_options before calling cpp_start_read.  Only
+   must call cpp_post_options before calling cpp_read_main_file.  Only
    after cpp_post_options are the contents of the cpp_options
-   structure reliable.  */
+   structure reliable.  Options processing is not completed until you
+   call cpp_finish_options.  */
 extern int cpp_handle_options PARAMS ((cpp_reader *, int, char **));
 extern int cpp_handle_option PARAMS ((cpp_reader *, int, char **));
 extern void cpp_post_options PARAMS ((cpp_reader *));
 
+/* This function reads the file, but does not start preprocessing.  It
+   returns the name of the original file; this is the same as the
+   input file, except for preprocessed input.  This will generate at
+   least one file change callback, and possibly a line change callback
+   too.  If there was an error opening the file, it returns NULL.
+
+   If you want cpplib to manage its own hashtable, pass in a NULL
+   pointer.  Otherise you should pass in an initialised hash table
+   that cpplib will share; this technique is used by the C front
+   ends.  */
+extern const char *cpp_read_main_file PARAMS ((cpp_reader *, const char *,
+					       struct ht *));
+
+/* Deferred handling of command line options that can generate debug
+   callbacks, such as -D and -imacros.  Call this after
+   cpp_read_main_file.  The front ends need this separation so they
+   can initialize debug output with the original file name, returned
+   from cpp_read_main_file, before they get debug callbacks.  */
+extern void cpp_finish_options PARAMS ((cpp_reader *));
+
+/* Call this to release the handle at the end of preprocessing.  Any
+   use of the handle after this function returns is invalid.  Returns
+   cpp_errors (pfile).  */
+extern int cpp_destroy PARAMS ((cpp_reader *));
+
 /* Error count.  */
 extern unsigned int cpp_errors PARAMS ((cpp_reader *));
 
@@ -495,7 +513,6 @@ extern void cpp_register_pragma PARAMS (
 					 const char *, const char *,
 					 void (*) PARAMS ((cpp_reader *))));
 
-extern int cpp_start_read PARAMS ((cpp_reader *, const char *));
 extern void cpp_finish PARAMS ((cpp_reader *));
 extern int cpp_avoid_paste PARAMS ((cpp_reader *, const cpp_token *,
 				    const cpp_token *));
============================================================
Index: gcc/cppmain.c
--- gcc/cppmain.c	2001/11/10 04:46:01	1.85
+++ gcc/cppmain.c	2001/11/12 10:38:16
@@ -77,7 +77,7 @@ main (argc, argv)
   general_init (argv[0]);
 
   /* Contruct a reader with default language GNU C89.  */
-  pfile = cpp_create_reader (NULL, CLK_GNUC89);
+  pfile = cpp_create_reader (CLK_GNUC89);
   options = cpp_get_options (pfile);
   
   do_preprocessing (argc, argv);
@@ -117,10 +117,12 @@ do_preprocessing (argc, argv)
     return;
 
   if (argi < argc)
-    cpp_fatal (pfile, "Invalid option %s", argv[argi]);
-  else
-    cpp_post_options (pfile);
+    {
+      cpp_fatal (pfile, "Invalid option %s", argv[argi]);
+      return;
+    }
 
+  cpp_post_options (pfile);
   if (CPP_FATAL_ERRORS (pfile))
     return;
 
@@ -156,8 +158,10 @@ do_preprocessing (argc, argv)
 
   setup_callbacks ();
 
-  if (cpp_start_read (pfile, options->in_fname))
+  if (cpp_read_main_file (pfile, options->in_fname, NULL))
     {
+      cpp_finish_options (pfile);
+
       /* A successful cpp_start_read guarantees that we can call
 	 cpp_scan_nooutput or cpp_get_token next.  */
       if (options->no_output)
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h	2001/11/09 23:30:24	1.8
+++ gcc/langhooks.h	2001/11/12 10:38:17
@@ -59,8 +59,10 @@ struct lang_hooks
      identifier nodes long enough for the language-specific slots.  */
   size_t identifier_size;
 
-  /* Called first, to initialize the front end.  */
-  void (*init) PARAMS ((void));
+  /* Called after options parsing, to initialize the front end.  The
+     main input filename is passed, which may be NULL; the front end
+     should return the original filename (e.g. foo.i -> foo.c).  */
+  const char * (*init) PARAMS ((const char *));
 
   /* Called last, as a finalizer.  */
   void (*finish) PARAMS ((void));
@@ -81,7 +83,7 @@ struct lang_hooks
      done for this option.  */
   int (*decode_option) PARAMS ((int, char **));
 
-  /* Called when all command line options have been processed.  */
+  /* Called when all command line options have been parsed.  */
   void (*post_options) PARAMS ((void));
 
   /* Called to obtain the alias set to be used for an expression or type.
============================================================
Index: gcc/toplev.c
--- gcc/toplev.c	2001/11/11 11:25:28	1.537
+++ gcc/toplev.c	2001/11/12 10:38:29
@@ -161,13 +161,20 @@ extern char **environ;
 extern int size_directive_output;
 extern tree last_assemble_variable_decl;
 
+static void general_init PARAMS ((char *));
+static void parse_options_and_default_flags PARAMS ((int, char **));
+static void process_options PARAMS ((void));
+static void lang_independent_init PARAMS ((void));
+static void lang_dependent_init PARAMS ((const char *));
+static void init_asm_output PARAMS ((const char *));
+
 static void set_target_switch PARAMS ((const char *));
 static const char *decl_name PARAMS ((tree, int));
 
 static void float_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
 static void crash_signal PARAMS ((int)) ATTRIBUTE_NORETURN;
 static void set_float_handler PARAMS ((jmp_buf));
-static void compile_file PARAMS ((const char *));
+static void compile_file PARAMS ((void));
 static void display_help PARAMS ((void));
 static void display_target_options PARAMS ((void));
 
@@ -232,7 +239,7 @@ extern int target_flags;
 
 /* Debug hooks - dependent upon command line options.  */
 
-struct gcc_debug_hooks *debug_hooks;
+struct gcc_debug_hooks *debug_hooks = &do_nothing_debug_hooks;
 
 /* Describes a dump file.  */
 
@@ -1438,23 +1445,6 @@ int warn_unused_parameter;
 int warn_unused_variable;
 int warn_unused_value;
 
-void
-set_Wunused (setting)
-     int setting;
-{
-  warn_unused_function = setting;
-  warn_unused_label = setting;
-  /* Unused function parameter warnings are reported when either ``-W
-     -Wunused'' or ``-Wunused-parameter'' is specified.  Differentiate
-     -Wunused by setting WARN_UNUSED_PARAMETER to -1.  */
-  if (!setting)
-    warn_unused_parameter = 0;
-  else if (!warn_unused_parameter)
-    warn_unused_parameter = -1;
-  warn_unused_variable = setting;
-  warn_unused_value = setting;
-}
-
 /* Nonzero to warn about code which is never reached.  */
 
 int warn_notreached;
@@ -1556,6 +1546,23 @@ lang_independent_options W_options[] =
    N_("Warn about functions which might be candidates for attribute noreturn") }
 };
 
+void
+set_Wunused (setting)
+     int setting;
+{
+  warn_unused_function = setting;
+  warn_unused_label = setting;
+  /* Unused function parameter warnings are reported when either ``-W
+     -Wunused'' or ``-Wunused-parameter'' is specified.  Differentiate
+     -Wunused by setting WARN_UNUSED_PARAMETER to -1.  */
+  if (!setting)
+    warn_unused_parameter = 0;
+  else if (!warn_unused_parameter)
+    warn_unused_parameter = -1;
+  warn_unused_variable = setting;
+  warn_unused_value = setting;
+}
+
 /* The following routines are useful in setting all the flags that
    -ffast-math and -fno-fast-math imply.  */
 
@@ -2132,203 +2139,14 @@ pop_srcloc ()
   lineno = input_file_stack->line;
 }
 
-/* Compile an entire translation unit, whose primary source file is
-   named NAME.  Write a file of assembly output and various debugging
-   dumps.  */
+/* Compile an entire translation unit.  Write a file of assembly
+   output and various debugging dumps.  */
 
 static void
-compile_file (name)
-     const char *name;
+compile_file ()
 {
   tree globals;
 
-  int name_specified = name != 0;
-
-  if (dump_base_name == 0)
-    dump_base_name = name ? name : "gccdump";
-
-  if (! quiet_flag)
-    time_report = 1;
-
-  /* Start timing total execution time.  */
-
-  init_timevar ();
-  timevar_start (TV_TOTAL);
-
-  /* Open assembly code output file.  Do this even if -fsyntax-only is on,
-     because then the driver will have provided the name of a temporary
-     file or bit bucket for us.  */
-
-  if (! name_specified && asm_file_name == 0)
-    asm_out_file = stdout;
-  else
-    {
-      if (asm_file_name == 0)
-        {
-          int len = strlen (dump_base_name);
-          char *dumpname = (char *) xmalloc (len + 6);
-          memcpy (dumpname, dump_base_name, len + 1);
-          strip_off_ending (dumpname, len);
-          strcat (dumpname, ".s");
-          asm_file_name = dumpname;
-        }
-      if (!strcmp (asm_file_name, "-"))
-        asm_out_file = stdout;
-      else
-        asm_out_file = fopen (asm_file_name, "w");
-      if (asm_out_file == 0)
-	fatal_io_error ("can't open %s for writing", asm_file_name);
-    }
-
-  /* Initialize data in various passes.  */
-
-  init_obstacks ();
-  name = init_parse (name);
-  init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
-		  || debug_info_level == DINFO_LEVEL_VERBOSE
-		  || flag_test_coverage
-		  || warn_notreached);
-  init_regs ();
-  init_alias_once ();
-  init_decl_processing ();
-  init_eh ();
-  init_optabs ();
-  init_stmt ();
-  init_loop ();
-  init_reload ();
-  init_function_once ();
-  init_stor_layout_once ();
-  init_varasm_once ();
-  init_EXPR_INSN_LIST_cache ();
-
-  /* The following initialization functions need to generate rtl, so
-     provide a dummy function context for them.  */
-  init_dummy_function_start ();
-  init_expmed ();
-  init_expr_once ();
-  if (flag_caller_saves)
-    init_caller_save ();
-  expand_dummy_function_end ();
-
-  /* If auxiliary info generation is desired, open the output file.
-     This goes in the same directory as the source file--unlike
-     all the other output files.  */
-  if (flag_gen_aux_info)
-    {
-      aux_info_file = fopen (aux_info_file_name, "w");
-      if (aux_info_file == 0)
-	fatal_io_error ("can't open %s", aux_info_file_name);
-    }
-
-#ifdef IO_BUFFER_SIZE
-  setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
-           _IOFBF, IO_BUFFER_SIZE);
-#endif
-
-  if (name != 0)
-    name = ggc_strdup (name);
-
-  input_filename = name;
-
-  /* Put an entry on the input file stack for the main input file.  */
-  push_srcloc (input_filename, 0);
-
-  /* Perform language-specific initialization.
-     This may set main_input_filename.  */
-  (*lang_hooks.init) ();
-
-  /* If the input doesn't start with a #line, use the input name
-     as the official input file name.  */
-  if (main_input_filename == 0)
-    main_input_filename = name;
-
-  if (flag_syntax_only)
-    {
-      write_symbols = NO_DEBUG;
-      profile_flag = 0;
-      profile_block_flag = 0;
-    }
-  else
-    {
-#ifdef ASM_FILE_START
-      ASM_FILE_START (asm_out_file);
-#endif
-
-#ifdef ASM_COMMENT_START
-      if (flag_verbose_asm)
-	{
-	  /* Print the list of options in effect.  */
-	  print_version (asm_out_file, ASM_COMMENT_START);
-	  print_switch_values (asm_out_file, 0, MAX_LINE,
-			       ASM_COMMENT_START, " ", "\n");
-	  /* Add a blank line here so it appears in assembler output but not
-	     screen output.  */
-	  fprintf (asm_out_file, "\n");
-	}
-#endif
-    } /* ! flag_syntax_only  */
-
-  /* Set up the debug hooks based on write_symbols.  Default to doing
-     nothing.  */
-  debug_hooks = &do_nothing_debug_hooks;  
-#if defined(DBX_DEBUGGING_INFO)
-  if (write_symbols == DBX_DEBUG)
-    debug_hooks = &dbx_debug_hooks;
-#endif
-#if defined(XCOFF_DEBUGGING_INFO)
-  if (write_symbols == XCOFF_DEBUG)
-    debug_hooks = &xcoff_debug_hooks;
-#endif
-#ifdef SDB_DEBUGGING_INFO
-  if (write_symbols == SDB_DEBUG)
-    debug_hooks = &sdb_debug_hooks;
-#endif
-#ifdef DWARF_DEBUGGING_INFO
-  if (write_symbols == DWARF_DEBUG)
-    debug_hooks = &dwarf_debug_hooks;
-#endif
-#ifdef DWARF2_DEBUGGING_INFO
-  if (write_symbols == DWARF2_DEBUG)
-    debug_hooks = &dwarf2_debug_hooks;
-#endif
-
-  if (! targetm.have_named_sections)
-    {
-      if (flag_function_sections)
-	{
-	  warning ("-ffunction-sections not supported for this target.");
-	  flag_function_sections = 0;
-	}
-      if (flag_data_sections)
-	{
-	  warning ("-fdata-sections not supported for this target.");
-	  flag_data_sections = 0;
-	}
-    }
-
-  if (flag_function_sections
-      && (profile_flag || profile_block_flag))
-    {
-      warning ("-ffunction-sections disabled; it makes profiling impossible.");
-      flag_function_sections = 0;
-    }
-
-#ifndef OBJECT_FORMAT_ELF
-  if (flag_function_sections && write_symbols != NO_DEBUG)
-    warning ("-ffunction-sections may affect debugging on some targets.");
-#endif
-
-  /* If dbx symbol table desired, initialize writing it
-     and output the predefined types.  */
-  timevar_push (TV_SYMOUT);
-#ifdef DWARF2_UNWIND_INFO
-  if (dwarf2out_do_frame ())
-    dwarf2out_frame_init ();
-#endif
-
-  (*debug_hooks->init) (main_input_filename);
-  timevar_pop (TV_SYMOUT);
-
   /* Initialize yet another pass.  */
 
   init_final (main_input_filename);
@@ -2491,13 +2309,6 @@ compile_file (name)
 
   /* Free up memory for the benefit of leak detectors.  */
   free_reg_info ();
-
-  /* Stop timing total execution time.  */
-  timevar_stop (TV_TOTAL);
-
-  /* Print the times.  */
-
-  timevar_print (stderr);
 }
 
 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
@@ -4591,27 +4402,241 @@ independent_decode_option (argc, argv)
   return 1;
 }
 
-/* Entry point of cc1, cc1plus, jc1, f771, etc.
-   Decode command args, then call compile_file.
-   Exit code is FATAL_EXIT_CODE if can't open files or if there were
-   any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
+/* Decode -m switches.  */
+/* Decode the switch -mNAME.  */
 
-   It is not safe to call this function more than once.  */
+static void
+set_target_switch (name)
+     const char *name;
+{
+  size_t j;
+  int valid_target_option = 0;
 
-int
-toplev_main (argc, argv)
-     int argc;
-     char **argv;
+  for (j = 0; j < ARRAY_SIZE (target_switches); j++)
+    if (!strcmp (target_switches[j].name, name))
+      {
+	if (target_switches[j].value < 0)
+	  target_flags &= ~-target_switches[j].value;
+	else
+	  target_flags |= target_switches[j].value;
+	valid_target_option = 1;
+      }
+
+#ifdef TARGET_OPTIONS
+  if (!valid_target_option)
+    for (j = 0; j < ARRAY_SIZE (target_options); j++)
+      {
+	int len = strlen (target_options[j].prefix);
+	if (!strncmp (target_options[j].prefix, name, len))
+	  {
+	    *target_options[j].variable = name + len;
+	    valid_target_option = 1;
+	  }
+      }
+#endif
+
+  if (!valid_target_option)
+    error ("Invalid option `%s'", name);
+}
+
+/* Print version information to FILE.
+   Each line begins with INDENT (for the case where FILE is the
+   assembler output file).  */
+
+static void
+print_version (file, indent)
+     FILE *file;
+     const char *indent;
 {
-  int i;
-  char *p;
+#ifndef __VERSION__
+#define __VERSION__ "[?]"
+#endif
+  fnotice (file,
+#ifdef __GNUC__
+	   "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
+#else
+	   "%s%s%s version %s (%s) compiled by CC.\n"
+#endif
+	   , indent, *indent != 0 ? " " : "",
+	   lang_hooks.name, version_string, TARGET_NAME,
+	   indent, __VERSION__);
+}
 
-  /* save in case md file wants to emit args as a comment.  */
-  save_argc = argc;
-  save_argv = argv;
+/* Print an option value and return the adjusted position in the line.
+   ??? We don't handle error returns from fprintf (disk full); presumably
+   other code will catch a disk full though.  */
 
-  p = argv[0] + strlen (argv[0]);
-  while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
+static int
+print_single_switch (file, pos, max, indent, sep, term, type, name)
+     FILE *file;
+     int pos, max;
+     const char *indent, *sep, *term, *type, *name;
+{
+  /* The ultrix fprintf returns 0 on success, so compute the result we want
+     here since we need it for the following test.  */
+  int len = strlen (sep) + strlen (type) + strlen (name);
+
+  if (pos != 0
+      && pos + len > max)
+    {
+      fprintf (file, "%s", term);
+      pos = 0;
+    }
+  if (pos == 0)
+    {
+      fprintf (file, "%s", indent);
+      pos = strlen (indent);
+    }
+  fprintf (file, "%s%s%s", sep, type, name);
+  pos += len;
+  return pos;
+}
+
+/* Print active target switches to FILE.
+   POS is the current cursor position and MAX is the size of a "line".
+   Each line begins with INDENT and ends with TERM.
+   Each switch is separated from the next by SEP.  */
+
+static void
+print_switch_values (file, pos, max, indent, sep, term)
+     FILE *file;
+     int pos, max;
+     const char *indent, *sep, *term;
+{
+  size_t j;
+  char **p;
+
+  /* Print the options as passed.  */
+
+  pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
+			     _("options passed: "), "");
+
+  for (p = &save_argv[1]; *p != NULL; p++)
+    if (**p == '-')
+      {
+	/* Ignore these.  */
+	if (strcmp (*p, "-o") == 0)
+	  {
+	    if (p[1] != NULL)
+	      p++;
+	    continue;
+	  }
+	if (strcmp (*p, "-quiet") == 0)
+	  continue;
+	if (strcmp (*p, "-version") == 0)
+	  continue;
+	if ((*p)[1] == 'd')
+	  continue;
+
+	pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
+      }
+  if (pos > 0)
+    fprintf (file, "%s", term);
+
+  /* Print the -f and -m options that have been enabled.
+     We don't handle language specific options but printing argv
+     should suffice.  */
+
+  pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
+			     _("options enabled: "), "");
+
+  for (j = 0; j < ARRAY_SIZE (f_options); j++)
+    if (*f_options[j].variable == f_options[j].on_value)
+      pos = print_single_switch (file, pos, max, indent, sep, term,
+				 "-f", f_options[j].string);
+
+  /* Print target specific options.  */
+
+  for (j = 0; j < ARRAY_SIZE (target_switches); j++)
+    if (target_switches[j].name[0] != '\0'
+	&& target_switches[j].value > 0
+	&& ((target_switches[j].value & target_flags)
+	    == target_switches[j].value))
+      {
+	pos = print_single_switch (file, pos, max, indent, sep, term,
+				   "-m", target_switches[j].name);
+      }
+
+#ifdef TARGET_OPTIONS
+  for (j = 0; j < ARRAY_SIZE (target_options); j++)
+    if (*target_options[j].variable != NULL)
+      {
+	char prefix[256];
+	sprintf (prefix, "-m%s", target_options[j].prefix);
+	pos = print_single_switch (file, pos, max, indent, sep, term,
+				   prefix, *target_options[j].variable);
+      }
+#endif
+
+  fprintf (file, "%s", term);
+}
+
+/* Open assembly code output file.  Do this even if -fsyntax-only is
+   on, because then the driver will have provided the name of a
+   temporary file or bit bucket for us.  NAME is the file specified on
+   the command line, possibly NULL.  */
+static void
+init_asm_output (name)
+     const char *name;
+{
+  if (name == NULL && asm_file_name == 0)
+    asm_out_file = stdout;
+  else
+    {
+      if (asm_file_name == 0)
+        {
+          int len = strlen (dump_base_name);
+          char *dumpname = (char *) xmalloc (len + 6);
+          memcpy (dumpname, dump_base_name, len + 1);
+          strip_off_ending (dumpname, len);
+          strcat (dumpname, ".s");
+          asm_file_name = dumpname;
+        }
+      if (!strcmp (asm_file_name, "-"))
+        asm_out_file = stdout;
+      else
+        asm_out_file = fopen (asm_file_name, "w");
+      if (asm_out_file == 0)
+	fatal_io_error ("can't open %s for writing", asm_file_name);
+    }
+
+#ifdef IO_BUFFER_SIZE
+  setvbuf (asm_out_file, (char *) xmalloc (IO_BUFFER_SIZE),
+           _IOFBF, IO_BUFFER_SIZE);
+#endif
+
+  if (!flag_syntax_only)
+    {
+#ifdef ASM_FILE_START
+      ASM_FILE_START (asm_out_file);
+#endif
+
+#ifdef ASM_COMMENT_START
+      if (flag_verbose_asm)
+	{
+	  /* Print the list of options in effect.  */
+	  print_version (asm_out_file, ASM_COMMENT_START);
+	  print_switch_values (asm_out_file, 0, MAX_LINE,
+			       ASM_COMMENT_START, " ", "\n");
+	  /* Add a blank line here so it appears in assembler output but not
+	     screen output.  */
+	  fprintf (asm_out_file, "\n");
+	}
+#endif
+    }
+}
+
+/* Initialization of the front end environment, before command line
+   options are parsed.  Signal handlers, internationalization etc.
+   ARGV0 is main's argv[0].  */
+static void
+general_init (argv0)
+     char *argv0;
+{
+  char *p;
+
+  p = argv0 + strlen (argv0);
+  while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
     --p;
   progname = p;
 
@@ -4640,29 +4665,28 @@ toplev_main (argc, argv)
   signal (SIGIOT, crash_signal);
 #endif
 
-  decl_printable_name = decl_name;
-  lang_expand_expr = (lang_expand_expr_t) do_abort;
-
-  /* Initialize whether `char' is signed.  */
-  flag_signed_char = DEFAULT_SIGNED_CHAR;
-#ifdef DEFAULT_SHORT_ENUMS
-  /* Initialize how much space enums occupy, by default.  */
-  flag_short_enums = DEFAULT_SHORT_ENUMS;
-#endif
-
-  tree_code_length[(int) IDENTIFIER_NODE]
-    = ((lang_hooks.identifier_size - sizeof (struct tree_common))
-       / sizeof (tree));
+  /* Initialize the diagnostics reporting machinery, so option parsing
+     can give warnings and errors.  */
+  diagnostic_initialize (global_dc);
+}
+
+/* Parse command line options and set default flag values, called
+   after language-independent option-independent intialization.  Do
+   minimal options processing.  Outputting diagnostics is OK, but GC
+   and identifier hashtables etc. are not initialized yet.  */
+static void
+parse_options_and_default_flags (argc, argv)
+     int argc;
+     char **argv;
+{
+  int i;
 
-  /* Initialize the garbage-collector.  */
-  init_ggc ();
-  init_stringpool ();
-  ggc_add_rtx_root (&stack_limit_rtx, 1);
-  ggc_add_tree_root (&current_function_decl, 1);
-  ggc_add_tree_root (&current_function_func_begin_label, 1);
+  /* Save in case md file wants to emit args as a comment.  */
+  save_argc = argc;
+  save_argv = argv;
 
-  /* Initialize the diagnostics reporting machinery.  */
-  diagnostic_initialize (global_dc);
+  /* Initialize register usage now so switches may override.  */
+  init_reg_sets ();
 
   /* Register the language-independent parameters.  */
   add_params (lang_independent_params, LAST_PARAM);
@@ -4758,6 +4782,13 @@ toplev_main (argc, argv)
       align_functions = 1;
     }
 
+  /* Initialize whether `char' is signed.  */
+  flag_signed_char = DEFAULT_SIGNED_CHAR;
+#ifdef DEFAULT_SHORT_ENUMS
+  /* Initialize how much space enums occupy, by default.  */
+  flag_short_enums = DEFAULT_SHORT_ENUMS;
+#endif
+
   /* Initialize target_flags before OPTIMIZATION_OPTIONS so the latter can
      modify it.  */
   target_flags = 0;
@@ -4774,9 +4805,6 @@ toplev_main (argc, argv)
   OPTIMIZATION_OPTIONS (optimize, optimize_size);
 #endif
 
-  /* Initialize register usage now so switches may override.  */
-  init_reg_sets ();
-
   /* Perform normal command line switch decoding.  */
   for (i = 1; i < argc;)
     {
@@ -4844,10 +4872,12 @@ toplev_main (argc, argv)
 
   /* All command line options have been processed.  */
   (*lang_hooks.post_options) ();
-
-  if (exit_after_options)
-    exit (0);
-
+}
+
+/* Process the options that have been parsed.  */
+static void
+process_options ()
+{
   /* Checker uses the frame pointer.  */
   if (flag_check_memory_usage)
     flag_omit_frame_pointer = 0;
@@ -4963,180 +4993,214 @@ toplev_main (argc, argv)
 	print_switch_values (stderr, 0, MAX_LINE, "", " ", "\n");
     }
 
-  compile_file (filename);
+  if (! quiet_flag)
+    time_report = 1;
 
-  if (errorcount)
-    return (FATAL_EXIT_CODE);
-  if (sorrycount)
-    return (FATAL_EXIT_CODE);
-  return (SUCCESS_EXIT_CODE);
+  if (flag_syntax_only)
+    {
+      write_symbols = NO_DEBUG;
+      profile_flag = 0;
+      profile_block_flag = 0;
+    }
+
+  /* Now we know write_symbols, set up the debug hooks based on it.
+     By default we do nothing for debug output.  */
+#if defined(DBX_DEBUGGING_INFO)
+  if (write_symbols == DBX_DEBUG)
+    debug_hooks = &dbx_debug_hooks;
+#endif
+#if defined(XCOFF_DEBUGGING_INFO)
+  if (write_symbols == XCOFF_DEBUG)
+    debug_hooks = &xcoff_debug_hooks;
+#endif
+#ifdef SDB_DEBUGGING_INFO
+  if (write_symbols == SDB_DEBUG)
+    debug_hooks = &sdb_debug_hooks;
+#endif
+#ifdef DWARF_DEBUGGING_INFO
+  if (write_symbols == DWARF_DEBUG)
+    debug_hooks = &dwarf_debug_hooks;
+#endif
+#ifdef DWARF2_DEBUGGING_INFO
+  if (write_symbols == DWARF2_DEBUG)
+    debug_hooks = &dwarf2_debug_hooks;
+#endif
+
+  /* If auxiliary info generation is desired, open the output file.
+     This goes in the same directory as the source file--unlike
+     all the other output files.  */
+  if (flag_gen_aux_info)
+    {
+      aux_info_file = fopen (aux_info_file_name, "w");
+      if (aux_info_file == 0)
+	fatal_io_error ("can't open %s", aux_info_file_name);
+    }
+
+  if (! targetm.have_named_sections)
+    {
+      if (flag_function_sections)
+	{
+	  warning ("-ffunction-sections not supported for this target.");
+	  flag_function_sections = 0;
+	}
+      if (flag_data_sections)
+	{
+	  warning ("-fdata-sections not supported for this target.");
+	  flag_data_sections = 0;
+	}
+    }
+
+  if (flag_function_sections
+      && (profile_flag || profile_block_flag))
+    {
+      warning ("-ffunction-sections disabled; it makes profiling impossible.");
+      flag_function_sections = 0;
+    }
+
+#ifndef OBJECT_FORMAT_ELF
+  if (flag_function_sections && write_symbols != NO_DEBUG)
+    warning ("-ffunction-sections may affect debugging on some targets.");
+#endif
 }
 
-/* Decode -m switches.  */
-/* Decode the switch -mNAME.  */
-
+/* Language-independent initialization, before language-dependent
+   initialization.  */
 static void
-set_target_switch (name)
-     const char *name;
+lang_independent_init ()
 {
-  size_t j;
-  int valid_target_option = 0;
+  decl_printable_name = decl_name;
+  lang_expand_expr = (lang_expand_expr_t) do_abort;
 
-  for (j = 0; j < ARRAY_SIZE (target_switches); j++)
-    if (!strcmp (target_switches[j].name, name))
-      {
-	if (target_switches[j].value < 0)
-	  target_flags &= ~-target_switches[j].value;
-	else
-	  target_flags |= target_switches[j].value;
-	valid_target_option = 1;
-      }
+  /* Set the language-dependent identifer size.  */
+  tree_code_length[(int) IDENTIFIER_NODE]
+    = ((lang_hooks.identifier_size - sizeof (struct tree_common))
+       / sizeof (tree));
 
-#ifdef TARGET_OPTIONS
-  if (!valid_target_option)
-    for (j = 0; j < ARRAY_SIZE (target_options); j++)
-      {
-	int len = strlen (target_options[j].prefix);
-	if (!strncmp (target_options[j].prefix, name, len))
-	  {
-	    *target_options[j].variable = name + len;
-	    valid_target_option = 1;
-	  }
-      }
-#endif
+  /* Initialize the garbage-collector, and string pools.  FIXME: We
+     should do this later, in independent_init () when we know we
+     actually want to compile something, but cpplib currently wants to
+     use the hash table immediately in cpp_create_reader.  */
+  init_ggc ();
+  ggc_add_rtx_root (&stack_limit_rtx, 1);
+  ggc_add_tree_root (&current_function_decl, 1);
+  ggc_add_tree_root (&current_function_func_begin_label, 1);
 
-  if (!valid_target_option)
-    error ("Invalid option `%s'", name);
+  init_stringpool ();
+  init_obstacks ();
+
+  init_emit_once (debug_info_level == DINFO_LEVEL_NORMAL
+		  || debug_info_level == DINFO_LEVEL_VERBOSE
+		  || flag_test_coverage
+		  || warn_notreached);
+  init_regs ();
+  init_alias_once ();
+  init_stmt ();
+  init_loop ();
+  init_reload ();
+  init_function_once ();
+  init_stor_layout_once ();
+  init_varasm_once ();
+  init_EXPR_INSN_LIST_cache ();
+
+  /* The following initialization functions need to generate rtl, so
+     provide a dummy function context for them.  */
+  init_dummy_function_start ();
+  init_expmed ();
+  init_expr_once ();
+  if (flag_caller_saves)
+    init_caller_save ();
+  expand_dummy_function_end ();
 }
 
-/* Print version information to FILE.
-   Each line begins with INDENT (for the case where FILE is the
-   assembler output file).  */
-
+/* Language-dependent initialization.  */
 static void
-print_version (file, indent)
-     FILE *file;
-     const char *indent;
+lang_dependent_init (name)
+     const char *name;
 {
-#ifndef __VERSION__
-#define __VERSION__ "[?]"
-#endif
-  fnotice (file,
-#ifdef __GNUC__
-	   "%s%s%s version %s (%s)\n%s\tcompiled by GNU C version %s.\n"
-#else
-	   "%s%s%s version %s (%s) compiled by CC.\n"
-#endif
-	   , indent, *indent != 0 ? " " : "",
-	   lang_hooks.name, version_string, TARGET_NAME,
-	   indent, __VERSION__);
-}
+  if (dump_base_name == 0)
+    dump_base_name = name ? name : "gccdump";
 
-/* Print an option value and return the adjusted position in the line.
-   ??? We don't handle error returns from fprintf (disk full); presumably
-   other code will catch a disk full though.  */
+  /* Front-end initialization.  This hook can assume that GC,
+     identifier hashes etc. are set up, but debug initialization is
+     not done yet.  This routine must return the original filename
+     (e.g. foo.i -> foo.c) so can correctly initialize debug output.  */
+  name = (*lang_hooks.init) (name);
 
-static int
-print_single_switch (file, pos, max, indent, sep, term, type, name)
-     FILE *file;
-     int pos, max;
-     const char *indent, *sep, *term, *type, *name;
-{
-  /* The ultrix fprintf returns 0 on success, so compute the result we want
-     here since we need it for the following test.  */
-  int len = strlen (sep) + strlen (type) + strlen (name);
+  if (name)
+    name = ggc_strdup (name);
 
-  if (pos != 0
-      && pos + len > max)
-    {
-      fprintf (file, "%s", term);
-      pos = 0;
-    }
-  if (pos == 0)
-    {
-      fprintf (file, "%s", indent);
-      pos = strlen (indent);
-    }
-  fprintf (file, "%s%s%s", sep, type, name);
-  pos += len;
-  return pos;
+  main_input_filename = input_filename = name;
+  init_asm_output (name);
+
+  /* These create various _DECL nodes, so need to be called after the
+     front end is initialized.  */
+  init_eh ();
+  init_optabs ();
+
+  /* Put an entry on the input file stack for the main input file.  */
+  push_srcloc (input_filename, 0);
+
+  /* If dbx symbol table desired, initialize writing it and output the
+     predefined types.  */
+  timevar_push (TV_SYMOUT);
+
+#ifdef DWARF2_UNWIND_INFO
+  if (dwarf2out_do_frame ())
+    dwarf2out_frame_init ();
+#endif
+
+  /* Now we have the correct original filename, we can initialize
+     debug output.  */
+  (*debug_hooks->init) (name);
+
+  timevar_pop (TV_SYMOUT);
 }
+
+/* Entry point of cc1, cc1plus, jc1, f771, etc.
+   Decode command args, then call compile_file.
+   Exit code is FATAL_EXIT_CODE if can't open files or if there were
+   any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
 
-/* Print active target switches to FILE.
-   POS is the current cursor position and MAX is the size of a "line".
-   Each line begins with INDENT and ends with TERM.
-   Each switch is separated from the next by SEP.  */
+   It is not safe to call this function more than once.  */
 
-static void
-print_switch_values (file, pos, max, indent, sep, term)
-     FILE *file;
-     int pos, max;
-     const char *indent, *sep, *term;
+int
+toplev_main (argc, argv)
+     int argc;
+     char **argv;
 {
-  size_t j;
-  char **p;
-
-  /* Print the options as passed.  */
+  /* Initialization of GCC's environment, and diagnostics.  */
+  general_init (argv [0]);
 
-  pos = print_single_switch (file, pos, max, indent, *indent ? " " : "", term,
-			     _("options passed: "), "");
+  /* Parse the options and do minimal processing; basically just
+     enough to default flags appropriately.  */
+  parse_options_and_default_flags (argc, argv);
 
-  for (p = &save_argv[1]; *p != NULL; p++)
-    if (**p == '-')
-      {
-	/* Ignore these.  */
-	if (strcmp (*p, "-o") == 0)
-	  {
-	    if (p[1] != NULL)
-	      p++;
-	    continue;
-	  }
-	if (strcmp (*p, "-quiet") == 0)
-	  continue;
-	if (strcmp (*p, "-version") == 0)
-	  continue;
-	if ((*p)[1] == 'd')
-	  continue;
+  /* Exit early if we can (e.g. -help).  */
+  if (exit_after_options)
+    return (SUCCESS_EXIT_CODE);
 
-	pos = print_single_switch (file, pos, max, indent, sep, term, *p, "");
-      }
-  if (pos > 0)
-    fprintf (file, "%s", term);
+  /* Start timing total execution time.  */
+  init_timevar ();
+  timevar_start (TV_TOTAL);
 
-  /* Print the -f and -m options that have been enabled.
-     We don't handle language specific options but printing argv
-     should suffice.  */
+  /* The bulk of command line switch processing.  */
+  process_options ();
 
-  pos = print_single_switch (file, 0, max, indent, *indent ? " " : "", term,
-			     _("options enabled: "), "");
+  /* Language-independent initialization.  Also sets up GC, identifier
+     hashes etc.  */
+  lang_independent_init ();
 
-  for (j = 0; j < ARRAY_SIZE (f_options); j++)
-    if (*f_options[j].variable == f_options[j].on_value)
-      pos = print_single_switch (file, pos, max, indent, sep, term,
-				 "-f", f_options[j].string);
+  /* Language-dependent initialization.  */
+  lang_dependent_init (filename);
 
-  /* Print target specific options.  */
+  compile_file ();
 
-  for (j = 0; j < ARRAY_SIZE (target_switches); j++)
-    if (target_switches[j].name[0] != '\0'
-	&& target_switches[j].value > 0
-	&& ((target_switches[j].value & target_flags)
-	    == target_switches[j].value))
-      {
-	pos = print_single_switch (file, pos, max, indent, sep, term,
-				   "-m", target_switches[j].name);
-      }
+  /* Stop timing and print the times.  */
+  timevar_stop (TV_TOTAL);
+  timevar_print (stderr);
 
-#ifdef TARGET_OPTIONS
-  for (j = 0; j < ARRAY_SIZE (target_options); j++)
-    if (*target_options[j].variable != NULL)
-      {
-	char prefix[256];
-	sprintf (prefix, "-m%s", target_options[j].prefix);
-	pos = print_single_switch (file, pos, max, indent, sep, term,
-				   prefix, *target_options[j].variable);
-      }
-#endif
+  if (errorcount || sorrycount)
+    return (FATAL_EXIT_CODE);
 
-  fprintf (file, "%s", term);
+  return (SUCCESS_EXIT_CODE);
 }
============================================================
Index: gcc/tree.h
--- gcc/tree.h	2001/11/09 23:30:25	1.281
+++ gcc/tree.h	2001/11/12 10:38:38
@@ -2647,7 +2647,6 @@ extern const char *(*decl_printable_name
 
 extern void (*incomplete_decl_finalize_hook)	PARAMS ((tree));
 
-extern const char *init_parse			PARAMS ((const char *));
 extern void finish_parse			PARAMS ((void));
 
 /* Declare a predefined function.  Return the declaration.  This function is
@@ -2774,9 +2773,6 @@ extern tree (*lang_type_promotes_to)	PAR
 extern tree fold_builtin		PARAMS ((tree));
 
 /* The language front-end must define these functions.  */
-
-/* Function of no arguments for initializing the symbol table.  */
-extern void init_decl_processing		PARAMS ((void));
 
 /* Function to replace the DECL_LANG_SPECIFIC field of a DECL with a copy.  */
 extern void copy_lang_decl			PARAMS ((tree));
============================================================
Index: gcc/ada/misc.c
--- gcc/ada/misc.c	2001/11/09 23:30:26	1.11
+++ gcc/ada/misc.c	2001/11/12 10:38:41
@@ -109,12 +109,13 @@ const char *gnat_tree_code_name[] = {
 };
 #undef DEFTREECODE
 
-static void gnat_init			PARAMS ((void));
+static const char *gnat_init		PARAMS ((const char *));
 static void gnat_init_options		PARAMS ((void));
 static int gnat_decode_option		PARAMS ((int, char **));
 static HOST_WIDE_INT gnat_get_alias_set	PARAMS ((tree));
 static void gnat_print_decl		PARAMS ((FILE *, tree, int));
 static void gnat_print_type		PARAMS ((FILE *, tree, int));
+extern void gnat_init_decl_processing	PARAMS ((void));
 
 /* Structure giving our language-specific hooks.  */
 
@@ -342,11 +343,38 @@ internal_error_function (msgid, ap)
 
 /* Perform all the initialization steps that are language-specific.  */
 
-void
-gnat_init ()
+static const char *
+gnat_init (filename)
+     const char *filename;
 {
+/* Performs whatever initialization steps needed by the language-dependent
+   lexical analyzer.
+
+   Define the additional tree codes here.  This isn't the best place to put
+   it, but it's where g++ does it.  */
+
+  lang_expand_expr = gnat_expand_expr;
+  lang_expand_constant = gnat_expand_constant;
+
+  memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
+	  (char *) gnat_tree_code_type,
+	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
+	   * sizeof (char *)));
+
+  memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
+	  (char *) gnat_tree_code_length,
+	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
+	   * sizeof (int)));
+
+  memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
+	  (char *) gnat_tree_code_name,
+	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
+	   * sizeof (char *)));
+
+  gnat_init_decl_processing ();
+
   /* Add the input filename as the last argument.  */
-  gnat_argv [gnat_argc] = (char *) input_filename;
+  gnat_argv [gnat_argc] = (char *) filename;
   gnat_argc++;
   gnat_argv [gnat_argc] = 0;
 
@@ -365,6 +393,8 @@ gnat_init ()
 #if defined(MIPS_DEBUGGING_INFO) && defined(DWARF2_DEBUGGING_INFO)
   dwarf2out_set_demangle_name_func (convert_ada_name_to_qualified_name);
 #endif
+
+  return filename;
 }
 
 /* If DECL has a cleanup, build and return that cleanup here.
@@ -847,37 +877,6 @@ insert_code_for (gnat_node)
       end_sequence ();
       emit_insns_after (insns, RTL_EXPR_RTL (get_gnu_tree (gnat_node)));
     }
-}
-
-/* Performs whatever initialization steps needed by the language-dependent
-   lexical analyzer.
-
-   Define the additional tree codes here.  This isn't the best place to put
-   it, but it's where g++ does it.  */
-
-const char *
-init_parse (filename)
-     const char *filename;
-{
-  lang_expand_expr = gnat_expand_expr;
-  lang_expand_constant = gnat_expand_constant;
-
-  memcpy ((char *) (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
-	  (char *) gnat_tree_code_type,
-	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (char *)));
-
-  memcpy ((char *) (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
-	  (char *) gnat_tree_code_length,
-	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (int)));
-
-  memcpy ((char *) (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
-	  (char *) gnat_tree_code_name,
-	  ((LAST_GNAT_TREE_CODE - (int) LAST_AND_UNUSED_TREE_CODE)
-	   * sizeof (char *)));
-
-  return filename;
 }
 
 void
============================================================
Index: gcc/ada/utils.c
--- gcc/ada/utils.c	2001/11/09 07:14:15	1.3
+++ gcc/ada/utils.c	2001/11/12 10:38:49
@@ -478,7 +478,7 @@ pushdecl (decl)
    front end has been run.  */
 
 void
-init_decl_processing ()
+gnat_init_decl_processing ()
 {
   lineno = 0;
 
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h	2001/11/09 23:30:27	1.653
+++ gcc/cp/cp-tree.h	2001/11/12 10:39:00
@@ -3458,6 +3458,9 @@ enum overload_flags { NO_SPECIAL = 0, DT
    : TYPE_NAME (NODE))
 
 /* in lex.c  */
+
+extern void init_reswords PARAMS ((void));
+
 /* Indexed by TREE_CODE, these tables give C-looking names to
    operators represented by TREE_CODES.  For example,
    opname_tab[(int) MINUS_EXPR] == "-".  */
@@ -3569,6 +3572,7 @@ extern void adjust_clone_args			PARAMS (
 
 /* decl.c */
 /* resume_binding_level */
+extern void cxx_init_decl_processing		PARAMS ((void));
 extern int toplevel_bindings_p			PARAMS ((void));
 extern int namespace_bindings_p			PARAMS ((void));
 extern void keep_next_level			PARAMS ((int));
@@ -3882,7 +3886,7 @@ extern void yyerror				PARAMS ((const ch
 extern void clear_inline_text_obstack		PARAMS ((void));
 extern void yyhook				PARAMS ((int));
 extern int cp_type_qual_from_rid                PARAMS ((tree));
-extern void cxx_init PARAMS ((void));
+extern const char *cxx_init			PARAMS ((const char *));
 extern void cxx_finish PARAMS ((void));
 extern void cxx_init_options PARAMS ((void));
 extern void cxx_post_options PARAMS ((void));
============================================================
Index: gcc/cp/decl.c
--- gcc/cp/decl.c	2001/11/08 19:04:43	1.823
+++ gcc/cp/decl.c	2001/11/12 10:39:36
@@ -6390,7 +6390,7 @@ initialize_predefined_identifiers ()
    Make definitions for built-in primitive functions.  */
 
 void
-init_decl_processing ()
+cxx_init_decl_processing ()
 {
   tree void_ftype;
   tree void_ftype_ptr;
@@ -6522,8 +6522,6 @@ init_decl_processing ()
 
   /* Indirecting an UNKNOWN_TYPE node yields an UNKNOWN_TYPE node.  */
   TREE_TYPE (unknown_type_node) = unknown_type_node;
-
-  TREE_TYPE (null_node) = type_for_size (POINTER_SIZE, 0);
 
   /* Looking up TYPE_POINTER_TO and TYPE_REFERENCE_TO yield the same
      result.  */
============================================================
Index: gcc/cp/lex.c
--- gcc/cp/lex.c	2001/11/09 23:30:28	1.255
+++ gcc/cp/lex.c	2001/11/12 10:39:39
@@ -53,7 +53,6 @@ extern void yyprint PARAMS ((FILE *, int
 
 static int interface_strcmp PARAMS ((const char *));
 static int *init_cpp_parse PARAMS ((void));
-static void init_reswords PARAMS ((void));
 static void init_cp_pragma PARAMS ((void));
 
 static tree parse_strconst_pragma PARAMS ((const char *, int));
@@ -248,7 +247,7 @@ cxx_post_options ()
 void
 cxx_init_options ()
 {
-  parse_in = cpp_create_reader (ident_hash, CLK_GNUCXX);
+  parse_in = cpp_create_reader (CLK_GNUCXX);
 
   /* Default exceptions on.  */
   flag_exceptions = 1;
@@ -263,15 +262,6 @@ cxx_init_options ()
 }
 
 void
-cxx_init ()
-{
-  c_common_lang_init ();
-
-  if (flag_gnu_xref) GNU_xref_begin (input_filename);
-  init_repo (input_filename);
-}
-
-void
 cxx_finish ()
 {
   if (flag_gnu_xref)
@@ -636,7 +626,7 @@ const short rid_to_yy[RID_MAX] =
   /* RID_AT_IMPLEMENTATION */	0
 };
 
-static void
+void
 init_reswords ()
 {
   unsigned int i;
@@ -676,17 +666,18 @@ init_cp_pragma ()
 		       handle_pragma_java_exceptions);
 }
 
+/* Initialize the C++ front end.  This function is very sensitive to
+   the exact order that things are done here.  It would be nice if the
+   initialization done by this routine were moved to its subroutines,
+   and the ordering dependencies clarified and reduced.  */
 const char *
-init_parse (filename)
+cxx_init (filename)
      const char *filename;
 {
   decl_printable_name = lang_printable_name;
-
   input_filename = "<internal>";
 
   init_reswords ();
-  init_pragma ();
-  init_cp_pragma ();
   init_spew ();
   init_tree ();
   init_cplus_expand ();
@@ -726,17 +717,28 @@ init_parse (filename)
   TREE_TYPE (enum_type_node) = enum_type_node;
   ridpointers[(int) RID_ENUM] = enum_type_node;
 
+  cxx_init_decl_processing ();
+
   /* Create the built-in __null node.  Note that we can't yet call for
      type_for_size here because integer_type_node and so forth are not
      set up.  Therefore, we don't set the type of these nodes until
-     init_decl_processing.  */
+     cxx_init_decl_processing.  */
   null_node = build_int_2 (0, 0);
+  TREE_TYPE (null_node) = type_for_size (POINTER_SIZE, 0);
   ridpointers[RID_NULL] = null_node;
 
   token_count = init_cpp_parse ();
   interface_unknown = 1;
 
-  return init_c_lex (filename);
+  filename = c_common_lang_init (filename);
+
+  init_cp_pragma ();
+
+  if (flag_gnu_xref)
+    GNU_xref_begin (filename);
+  init_repo (filename);
+
+  return filename;
 }
 
 void
============================================================
Index: gcc/cp/spew.c
--- gcc/cp/spew.c	2001/10/28 19:25:00	1.54
+++ gcc/cp/spew.c	2001/11/12 10:39:42
@@ -173,7 +173,7 @@ static tree defarg_parm;    /* current d
 static tree defarg_depfns;  /* list of unprocessed fns met during current fn. */
 static tree defarg_fnsdone; /* list of fns with circular defargs */
 
-/* Initialize obstacks. Called once, from init_parse.  */
+/* Initialize obstacks. Called once, from cxx_init.  */
 
 void
 init_spew ()
============================================================
Index: gcc/f/com.c
--- gcc/f/com.c	2001/11/09 23:30:40	1.139
+++ gcc/f/com.c	2001/11/12 10:40:14
@@ -260,6 +260,7 @@ struct _ffecom_concat_list_
 
 /* Static functions (internal). */
 
+static void ffecom_init_decl_processing PARAMS ((void));
 static tree ffecom_arglist_expr_ (const char *argstring, ffebld args);
 static tree ffecom_widest_expr_type_ (ffebld list);
 static bool ffecom_overlap_ (tree dest_decl, tree dest_offset,
@@ -14120,8 +14121,8 @@ mark_binding_level (void *arg)
     }
 }
 
-void
-init_decl_processing ()
+static void
+ffecom_init_decl_processing ()
 {
   static tree *const tree_roots[] = {
     &current_function_decl,
@@ -14188,31 +14189,6 @@ init_decl_processing ()
   ffe_init_0 ();
 }
 
-const char *
-init_parse (filename)
-     const char *filename;
-{
-  /* Open input file.  */
-  if (filename == 0 || !strcmp (filename, "-"))
-    {
-      finput = stdin;
-      filename = "stdin";
-    }
-  else
-    finput = fopen (filename, "r");
-  if (finput == 0)
-    fatal_io_error ("can't open %s", filename);
-
-#ifdef IO_BUFFER_SIZE
-  setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
-#endif
-
-  decl_printable_name = lang_printable_name;
-  print_error_function = lang_print_error_function;
-
-  return filename;
-}
-
 void
 finish_parse ()
 {
@@ -14253,7 +14229,7 @@ insert_block (block)
 }
 
 /* Each front end provides its own.  */
-static void ffe_init PARAMS ((void));
+static const char *ffe_init PARAMS ((const char *));
 static void ffe_finish PARAMS ((void));
 static void ffe_init_options PARAMS ((void));
 static void ffe_print_identifier PARAMS ((FILE *, tree, int));
@@ -14281,6 +14257,45 @@ static void ffe_print_identifier PARAMS 
 
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
+static const char *
+ffe_init (filename)
+     const char *filename;
+{
+  /* Open input file.  */
+  if (filename == 0 || !strcmp (filename, "-"))
+    {
+      finput = stdin;
+      filename = "stdin";
+    }
+  else
+    finput = fopen (filename, "r");
+  if (finput == 0)
+    fatal_io_error ("can't open %s", filename);
+
+#ifdef IO_BUFFER_SIZE
+  setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
+#endif
+
+  ffecom_init_decl_processing ();
+  decl_printable_name = lang_printable_name;
+  print_error_function = lang_print_error_function;
+
+  /* If the file is output from cpp, it should contain a first line
+     `# 1 "real-filename"', and the current design of gcc (toplev.c
+     in particular and the way it sets up information relied on by
+     INCLUDE) requires that we read this now, and store the
+     "real-filename" info in master_input_filename.  Ask the lexer
+     to try doing this.  */
+  ffelex_hash_kludge (finput);
+
+  /* FIXME: The ffelex_hash_kludge code needs to be cleaned up to
+     return the new file name.  */
+  if (main_input_filename)
+    filename = main_input_filename;
+
+  return filename;
+}
+
 static void
 ffe_finish ()
 {
@@ -14300,18 +14315,6 @@ ffe_init_options ()
   flag_merge_constants = 2;
   flag_errno_math = 0;
   flag_complex_divide_method = 1;
-}
-
-static void
-ffe_init ()
-{
-  /* If the file is output from cpp, it should contain a first line
-     `# 1 "real-filename"', and the current design of gcc (toplev.c
-     in particular and the way it sets up information relied on by
-     INCLUDE) requires that we read this now, and store the
-     "real-filename" info in master_input_filename.  Ask the lexer
-     to try doing this.  */
-  ffelex_hash_kludge (finput);
 }
 
 int
============================================================
Index: gcc/java/decl.c
--- gcc/java/decl.c	2001/09/22 18:50:09	1.109
+++ gcc/java/decl.c	2001/11/12 10:40:18
@@ -398,7 +398,7 @@ create_primitive_vtable (name)
 }
 
 void
-init_decl_processing ()
+java_init_decl_processing ()
 {
   register tree endlink;
   tree field = NULL_TREE;
============================================================
Index: gcc/java/java-tree.h
--- gcc/java/java-tree.h	2001/11/09 23:30:43	1.124
+++ gcc/java/java-tree.h	2001/11/12 10:40:23
@@ -1031,6 +1031,7 @@ extern tree ident_subst PARAMS ((const c
 				const char*, int, int, const char*));
 extern tree identifier_subst PARAMS ((const tree,
 				     const char *, int, int, const char *));
+extern void java_init_decl_processing PARAMS ((void));
 extern tree build_java_signature PARAMS ((tree));
 extern tree build_java_argument_signature PARAMS ((tree));
 extern void set_java_signature PARAMS ((tree, tree));
============================================================
Index: gcc/java/lang.c
--- gcc/java/lang.c	2001/11/09 23:30:43	1.78
+++ gcc/java/lang.c	2001/11/12 10:40:24
@@ -48,7 +48,7 @@ struct string_option
   int on_value;
 };
 
-static void java_init PARAMS ((void));
+static const char *java_init PARAMS ((const char *));
 static void java_init_options PARAMS ((void));
 static int java_decode_option PARAMS ((int, char **));
 static void put_decl_string PARAMS ((const char *, int));
@@ -186,7 +186,7 @@ lang_W_options[] =
 JCF *current_jcf;
 
 /* Variable controlling how dependency tracking is enabled in
-   init_parse.  */
+   java_init.  */
 static int dependency_tracking = 0;
 
 /* Flag values for DEPENDENCY_TRACKING.  */
@@ -411,10 +411,15 @@ java_decode_option (argc, argv)
 /* Global open file.  */
 FILE *finput;
 
-const char *
-init_parse (filename)
+static const char *
+java_init (filename)
      const char *filename;
 {
+#if 0
+  extern int flag_minimal_debug;
+  flag_minimal_debug = 0;
+#endif
+
   /* Open input file.  */
 
   if (filename == 0 || !strcmp (filename, "-"))
@@ -476,6 +481,30 @@ init_parse (filename)
 	}
     }
 
+  jcf_path_init ();
+  jcf_path_seal (version_flag);
+
+  decl_printable_name = lang_printable_name;
+  print_error_function = lang_print_error;
+  lang_expand_expr = java_lang_expand_expr;
+
+  /* Append to Gcc tree node definition arrays */
+
+  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
+	  java_tree_code_type,
+	  (int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
+  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
+	  java_tree_code_length,
+	  (LAST_JAVA_TREE_CODE - 
+	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
+  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
+	  java_tree_code_name,
+	  (LAST_JAVA_TREE_CODE - 
+	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
+  java_init_decl_processing ();
+
+  using_eh_for_cleanups ();
+
   return filename;
 }
 
@@ -675,38 +704,6 @@ lang_print_error (context, file)
       last_error_function = current_function_decl;
     }
 
-}
-
-static void
-java_init ()
-{
-#if 0
-  extern int flag_minimal_debug;
-  flag_minimal_debug = 0;
-#endif
-
-  jcf_path_init ();
-  jcf_path_seal (version_flag);
-
-  decl_printable_name = lang_printable_name;
-  print_error_function = lang_print_error;
-  lang_expand_expr = java_lang_expand_expr;
-
-  /* Append to Gcc tree node definition arrays */
-
-  memcpy (tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE,
-	  java_tree_code_type,
-	  (int)LAST_JAVA_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE);
-  memcpy (tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE,
-	  java_tree_code_length,
-	  (LAST_JAVA_TREE_CODE - 
-	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
-  memcpy (tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE,
-	  java_tree_code_name,
-	  (LAST_JAVA_TREE_CODE - 
-	   (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
-
-  using_eh_for_cleanups ();
 }
 
 /* This doesn't do anything on purpose. It's used to satisfy the
============================================================
Index: gcc/objc/objc-act.c
--- gcc/objc/objc-act.c	2001/11/12 00:02:36	1.104
+++ gcc/objc/objc-act.c	2001/11/12 10:40:37
@@ -157,7 +157,7 @@ char *util_firstobj;
 
 static void init_objc				PARAMS ((void));
 static void finish_objc				PARAMS ((void));
-static void objc_init				PARAMS ((void));
+static const char *objc_init			PARAMS ((const char *));
 static void objc_init_options			PARAMS ((void));
 static int objc_decode_option			PARAMS ((int, char **));
 static void objc_post_options			PARAMS ((void));
@@ -545,20 +545,25 @@ generate_struct_by_value_array ()
 static void
 objc_init_options ()
 {
-  parse_in = cpp_create_reader (ident_hash, CLK_OBJC);
+  parse_in = cpp_create_reader (CLK_OBJC);
   c_language = clk_objective_c;
 }
 
-static void
-objc_init ()
+static const char *
+objc_init (filename)
+     const char *filename;
 {
+  c_init_decl_processing ();
+
+  filename = c_common_lang_init (filename);
+
+  add_c_tree_codes ();
+
   /* Force the line number back to 0; check_newline will have
      raised it to 1, which will make the builtin functions appear
      not to be built in.  */
   lineno = 0;
 
-  c_common_lang_init ();
-
   /* If gen_declaration desired, open the output file.  */
   if (flag_gen_declaration)
     {
@@ -595,10 +600,11 @@ objc_init ()
     generate_struct_by_value_array ();
 
   objc_act_parse_init ();
-  c_parse_init ();
 
   VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
   ggc_add_tree_varray_root (&deferred_fns, 1);
+
+  return filename;
 }
 
 /* Register a function tree, so that its optimization and conversion


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