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]

RFA: More initialization tweaks


The idea of this patch is to move the call to cpp_read_main_file
to the post_options hook from the init langhook in the C front
ends, so that we can get the original filename of preprocessed
input earlier, and (in a future patch) initialize debugging earlier.

This requires updating the langhook prototypes.  I also took the
opportunity to remove lots of unnecessary casts from treelang
rather than add more.  The changes to other front ends are
just moving bits of code between the two hooks.

Bootstrapped and regtested x86 Linux.  OK?

Neil.

	* c-common.h (c_common_init, c_common_post_options): Update.
	* c-objc-common.c (c_objc_common_init): Update for new prototype.
	* c-opts.c (saved_lineno): New.
	(c_common_post_options, c_common_init): Update prototypes,
	move call to cpp_read_main_file from latter to former.
	* c-tree.h (c_ojbc_common_init): Update.
	* langhooks-def.h (lhd_post_options): New.
	(LANG_HOOKS_INIT, LANG_HOOKS_POST_OPTIONS): Update.
	* langhooks.c (lhd_post_options): New.
	* langhooks.h (struct lang_hooks): Update post_options and init hooks.
	* toplev.c (no_backend): New.
	(process_options): Call post_options hook and set main_input_filename
	and input_filename here.
	(lang_dependent_init, do_compile): post_options hook moved to
	process_options.
	* objc/objc-act.c (objc_init): Update prototype.
	* objc/objc-act.h (objc_init): Update prototype.
ada:
	* misc.c (gnat_init): Update for new prototype.
cp:
	* cp-tree.h (cxx_init): Update prototype.
	* lex.c (cxx_init): Similarly.
f:
	* com.c (ffe_init): Update prototype; move code to ffe_post_options.
	(ffe_post_options): New.
java:
	* lang.c (java_init): Update prototype, move code to java_post_options.
	(java_post_options): Similarly.
treelang:
	* tree1.c (in_fname): Fix type.
	(treelang_init): Update prototype and use of in_fname.
	* treelang.h (in_fname): Fix type.
	* treetree.c (tree_code_if_start, tree_code_if_else,
	tree_code_if_end, tree_code_create_function_prototype,
	tree_code_create_function_initial, tree_code_create_funciton_wrapup,
	tree_code_create_variable, tree_code_output_expression_statement)
	: Fix prototypes and use of filenames.
	* treetree.h: Similarly.


============================================================
Index: gcc/c-common.h
--- gcc/c-common.h	6 Mar 2003 23:12:29 -0000	1.169
+++ gcc/c-common.h	8 Mar 2003 12:59:09 -0000
@@ -961,8 +961,8 @@ extern void disable_builtin_function		PA
 extern tree build_va_arg			PARAMS ((tree, tree));
 
 extern void c_common_init_options		PARAMS ((enum c_language_kind));
-extern bool c_common_post_options		PARAMS ((void));
-extern const char *c_common_init		PARAMS ((const char *));
+extern bool c_common_post_options		PARAMS ((const char **));
+extern bool c_common_init			PARAMS ((void));
 extern void c_common_finish			PARAMS ((void));
 extern void c_common_parse_file			PARAMS ((int));
 extern HOST_WIDE_INT c_common_get_alias_set	PARAMS ((tree));
============================================================
Index: gcc/c-objc-common.c
--- gcc/c-objc-common.c	22 Feb 2003 10:02:29 -0000	1.22
+++ gcc/c-objc-common.c	8 Mar 2003 12:59:09 -0000
@@ -241,15 +241,13 @@ c_warn_unused_global_decl (decl)
 }
 
 /* Initialization common to C and Objective-C front ends.  */
-const char *
-c_objc_common_init (filename)
-     const char *filename;
+bool
+c_objc_common_init ()
 {
   c_init_decl_processing ();
 
-  filename = c_common_init (filename);
-  if (filename == NULL)
-    return NULL;
+  if (c_common_init () == false)
+    return false;
 
   lang_expand_decl_stmt = c_expand_decl_stmt;
 
@@ -271,7 +269,7 @@ c_objc_common_init (filename)
 
   VARRAY_TREE_INIT (deferred_fns, 32, "deferred_fns");
 
-  return filename;
+  return true;
 }
 
 /* Register a function tree, so that its optimization and conversion
============================================================
Index: gcc/c-opts.c
--- gcc/c-opts.c	6 Mar 2003 23:12:30 -0000	1.32
+++ gcc/c-opts.c	8 Mar 2003 12:59:09 -0000
@@ -39,6 +39,8 @@ Software Foundation, 59 Temple Place - S
 # define TARGET_SYSTEM_ROOT NULL
 #endif
 
+static int saved_lineno;
+
 /* CPP's options.  */
 static cpp_options *cpp_opts;
 
@@ -1442,7 +1444,8 @@ c_common_decode_option (argc, argv)
 
 /* Post-switch processing.  */
 bool
-c_common_post_options ()
+c_common_post_options (pfilename)
+     const char **pfilename;
 {
   /* Canonicalize the input and output filenames.  */
   if (in_fname == NULL || !strcmp (in_fname, "-"))
@@ -1492,26 +1495,6 @@ c_common_post_options ()
   if (warn_missing_format_attribute && !warn_format)
     warning ("-Wmissing-format-attribute ignored without -Wformat");
 
-  /* If an error has occurred in cpplib, note it so we fail
-     immediately.  */
-  errorcount += cpp_errors (parse_in);
-
-  return flag_preprocess_only;
-}
-
-/* Front end initialization common to C, ObjC and C++.  */
-const char *
-c_common_init (filename)
-     const char *filename;
-{
-  /* 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);
-  cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
-  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);
-
   if (flag_preprocess_only)
     {
       /* Open the output now.  We must do so even if flag_no_output is
@@ -1539,19 +1522,43 @@ c_common_init (filename)
     }
 
   /* NOTE: we use in_fname here, not the one supplied.  */
-  filename = cpp_read_main_file (parse_in, in_fname, ident_hash);
+  *pfilename = cpp_read_main_file (parse_in, in_fname, ident_hash);
+
+  saved_lineno = lineno;
+  lineno = 0;
+
+  /* If an error has occurred in cpplib, note it so we fail
+     immediately.  */
+  errorcount += cpp_errors (parse_in);
+
+  return flag_preprocess_only;
+}
+
+/* Front end initialization common to C, ObjC and C++.  */
+bool
+c_common_init ()
+{
+  lineno = 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);
+  cpp_opts->char_precision = TYPE_PRECISION (char_type_node);
+  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);
 
   if (flag_preprocess_only)
     {
-      if (filename)
+      if (main_input_filename)
 	preprocess_file (parse_in);
-      return NULL;
+      return false;
     }
 
   /* Has to wait until now so that cpplib has its hash table.  */
   init_pragma ();
 
-  return filename;
+  return true;
 }
 
 /* Common finish hook for the C, ObjC and C++ front ends.  */
============================================================
Index: gcc/c-tree.h
--- gcc/c-tree.h	12 Feb 2003 21:48:57 -0000	1.110
+++ gcc/c-tree.h	8 Mar 2003 12:59:09 -0000
@@ -245,7 +245,7 @@ extern tree make_pointer_declarator		PAR
 /* in c-objc-common.c */
 extern int c_disregard_inline_limits		PARAMS ((tree));
 extern int c_cannot_inline_tree_fn		PARAMS ((tree *));
-extern const char *c_objc_common_init		PARAMS ((const char *));
+extern bool c_objc_common_init			PARAMS ((void));
 extern int c_missing_noreturn_ok_p		PARAMS ((tree));
 extern void c_objc_common_finish_file		PARAMS ((void));
 extern int defer_fn				PARAMS ((tree));
============================================================
Index: gcc/langhooks-def.h
--- gcc/langhooks-def.h	19 Feb 2003 05:39:06 -0000	1.43
+++ gcc/langhooks-def.h	8 Mar 2003 12:59:09 -0000
@@ -46,6 +46,7 @@ extern void lhd_do_nothing_t PARAMS ((tr
 extern void lhd_do_nothing_i PARAMS ((int));
 extern void lhd_do_nothing_f PARAMS ((struct function *));
 extern int lhd_decode_option PARAMS ((int, char **));
+extern bool lhd_post_options PARAMS ((const char **));
 extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree));
 extern tree lhd_return_tree PARAMS ((tree));
 extern tree lhd_return_null_tree PARAMS ((tree));
@@ -86,13 +87,13 @@ void write_global_declarations PARAMS ((
 
 #define LANG_HOOKS_NAME			"GNU unknown"
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
-#define LANG_HOOKS_INIT			lhd_do_nothing
+#define LANG_HOOKS_INIT			hook_bool_void_false
 #define LANG_HOOKS_FINISH		lhd_do_nothing
 #define LANG_HOOKS_PARSE_FILE		lhd_do_nothing_i
 #define LANG_HOOKS_CLEAR_BINDING_STACK	lhd_clear_binding_stack
 #define LANG_HOOKS_INIT_OPTIONS		lhd_do_nothing
 #define LANG_HOOKS_DECODE_OPTION	lhd_decode_option
-#define LANG_HOOKS_POST_OPTIONS		hook_bool_void_false
+#define LANG_HOOKS_POST_OPTIONS		lhd_post_options
 #define LANG_HOOKS_GET_ALIAS_SET	lhd_get_alias_set
 #define LANG_HOOKS_EXPAND_CONSTANT	lhd_return_tree
 #define LANG_HOOKS_EXPAND_EXPR		lhd_expand_expr
============================================================
Index: gcc/langhooks.c
--- gcc/langhooks.c	8 Mar 2003 01:38:26 -0000	1.37
+++ gcc/langhooks.c	8 Mar 2003 12:59:09 -0000
@@ -93,6 +93,15 @@ lhd_decode_option (argc, argv)
   return 0;
 }
 
+/* The default post options hook.  */
+
+bool
+lhd_post_options (pfilename)
+     const char **pfilename ATTRIBUTE_UNUSED;
+{
+  return false;
+}
+
 /* Called from by print-tree.c.  */
 
 void
============================================================
Index: gcc/langhooks.h
--- gcc/langhooks.h	18 Feb 2003 18:50:00 -0000	1.51
+++ gcc/langhooks.h	8 Mar 2003 12:59:10 -0000
@@ -207,25 +207,20 @@ struct lang_hooks
      done for this option.  */
   int (*decode_option) PARAMS ((int, char **));
 
-  /* Called when all command line options have been parsed.  Should do
-     any required consistency checks, modifications etc.  Complex
-     initialization should be left to the "init" callback, since GC
-     and the identifier hashes are set up between now and then.
+  /* Called when all command line options have been parsed to allow
+     further processing and initialization
 
-     Should return zero unless the compiler back-end does not need to
-     be initialized, such as with the -E option.
+     Should return non-zero to indicate that a compiler back-end is
+     not required, such as with the -E option.
      
      If errorcount is nonzero after this call the compiler exits
      immediately and the finish hook is not called.  */
-  bool (*post_options) PARAMS ((void));
+  bool (*post_options) PARAMS ((const char **));
 
-  /* Called after post_options, 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).  Return NULL
-     to indicate a serious error of some sort; in that case no
-     compilation is performed, and the finish hook is called
-     immediately.  */
-  const char * (*init) PARAMS ((const char *));
+  /* Called after post_options to initialize the front end.  Return
+     false to indicate that no further compilation be performed, in
+     which case the finish hook is called immediately.  */
+  bool (*init) PARAMS ((void));
 
   /* Called at the end of compilation, as a finalizer.  */
   void (*finish) PARAMS ((void));
============================================================
Index: gcc/toplev.c
--- gcc/toplev.c	8 Mar 2003 01:38:27 -0000	1.732
+++ gcc/toplev.c	8 Mar 2003 12:59:11 -0000
@@ -104,7 +104,7 @@ extern void reg_alloc PARAMS ((void));
 
 static void general_init PARAMS ((char *));
 static void parse_options_and_default_flags PARAMS ((int, char **));
-static void do_compile PARAMS ((int));
+static void do_compile PARAMS ((void));
 static void process_options PARAMS ((void));
 static void backend_init PARAMS ((void));
 static int lang_dependent_init PARAMS ((const char *));
@@ -135,6 +135,9 @@ static void print_switch_values PARAMS (
 /* Nonzero to dump debug info whilst parsing (-dy option).  */
 static int set_yydebug;
 
+/* True if we don't need a backend (e.g. preprocessing only).  */
+static bool no_backend;
+
 /* Length of line when printing switch values.  */
 #define MAX_LINE 75
 
@@ -5169,6 +5172,13 @@ parse_options_and_default_flags (argc, a
 static void
 process_options ()
 {
+  /* Allow the front end to perform consistency checks and do further
+     initialization based on the command line options.  This hook also
+     sets the original filename if appropriate (e.g. foo.i -> foo.c)
+     so we can correctly initialize debug output.  */
+  no_backend = (*lang_hooks.post_options) (&filename);
+  main_input_filename = input_filename = filename;
+
 #ifdef OVERRIDE_OPTIONS
   /* Some machines may reject certain combinations of options.  */
   OVERRIDE_OPTIONS;
@@ -5411,15 +5421,10 @@ lang_dependent_init (name)
   if (dump_base_name == 0)
     dump_base_name = name ? name : "gccdump";
 
-  /* 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);
-  if (name == NULL)
+  /* Other front-end initialization.  */
+  if ((*lang_hooks.init) () == 0)
     return 0;
 
-  main_input_filename = input_filename = name;
   init_asm_output (name);
 
   /* These create various _DECL nodes, so need to be called after the
@@ -5513,8 +5518,7 @@ finalize ()
 
 /* Initialize the compiler, and compile the input file.  */
 static void
-do_compile (no_backend)
-     int no_backend;
+do_compile ()
 {
   /* We cannot start timing until after options are processed since that
      says if we run timers or not.  */
@@ -5558,16 +5562,11 @@ toplev_main (argc, argv)
   /* Exit early if we can (e.g. -help).  */
   if (!exit_after_options)
     {
-      /* All command line options have been parsed; allow the front
-	 end to perform consistency checks, etc.  */
-      bool no_backend = (*lang_hooks.post_options) ();
-
-      /* The bulk of command line switch processing.  */
       process_options ();
 
       /* Don't do any more if an error has already occurred.  */
       if (!errorcount)
-	do_compile (no_backend);
+	do_compile ();
     }
 
   if (errorcount || sorrycount)
============================================================
Index: gcc/ada/misc.c
--- gcc/ada/misc.c	16 Dec 2002 18:20:07 -0000	1.45
+++ gcc/ada/misc.c	8 Mar 2003 12:59:11 -0000
@@ -79,7 +79,7 @@ extern FILE *asm_out_file;
 extern int save_argc;
 extern char **save_argv;
 
-static const char *gnat_init		PARAMS ((const char *));
+static bool gnat_init			PARAMS ((void));
 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));
@@ -337,9 +337,8 @@ internal_error_function (msgid, ap)
 
 /* Perform all the initialization steps that are language-specific.  */
 
-static const char *
-gnat_init (filename)
-     const char *filename;
+static bool
+gnat_init ()
 {
   /* Performs whatever initialization steps needed by the language-dependent
      lexical analyzer.
@@ -350,7 +349,7 @@ gnat_init (filename)
   gnat_init_decl_processing ();
 
   /* Add the input filename as the last argument.  */
-  gnat_argv[gnat_argc] = (char *) filename;
+  gnat_argv[gnat_argc] = (char *) main_input_filename;
   gnat_argc++;
   gnat_argv[gnat_argc] = 0;
 
@@ -361,10 +360,7 @@ gnat_init (filename)
 
   set_lang_adjust_rli (gnat_adjust_rli);
 
-  if (filename == 0)
-    filename = "";
-
-  return filename;
+  return true;
 }
 
 /* If we are using the GCC mechanism for to process exception handling, we
============================================================
Index: gcc/cp/cp-tree.h
--- gcc/cp/cp-tree.h	8 Mar 2003 09:12:52 -0000	1.820
+++ gcc/cp/cp-tree.h	8 Mar 2003 12:59:13 -0000
@@ -3964,7 +3964,7 @@ extern tree make_aggr_type			(enum tree_
 extern void yyerror				(const char *);
 extern void yyhook				(int);
 extern int cp_type_qual_from_rid                (tree);
-extern const char *cxx_init			(const char *);
+extern bool cxx_init				(void);
 extern void cxx_finish (void);
 extern void cxx_init_options (void);
 
============================================================
Index: gcc/cp/lex.c
--- gcc/cp/lex.c	14 Feb 2003 06:04:41 -0000	1.300
+++ gcc/cp/lex.c	8 Mar 2003 12:59:13 -0000
@@ -406,9 +406,8 @@ init_cp_pragma ()
    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 *
-cxx_init (filename)
-     const char *filename;
+bool
+cxx_init (void)
 {
   input_filename = "<internal>";
 
@@ -446,15 +445,14 @@ cxx_init (filename)
 
   interface_unknown = 1;
 
-  filename = c_common_init (filename);
-  if (filename == NULL)
-    return NULL;
+  if (c_common_init () == false)
+    return false;
 
   init_cp_pragma ();
 
-  init_repo (filename);
+  init_repo (main_input_filename);
 
-  return filename;
+  return true;
 }
 
 /* Helper function to load global variables with interface
============================================================
Index: gcc/f/com.c
--- gcc/f/com.c	12 Jan 2003 02:32:39 -0000	1.183
+++ gcc/f/com.c	8 Mar 2003 12:59:17 -0000
@@ -14030,8 +14030,9 @@ insert_block (tree block)
 }
 
 /* Each front end provides its own.  */
-static const char *ffe_init PARAMS ((const char *));
+static bool ffe_init PARAMS ((void));
 static void ffe_finish PARAMS ((void));
+static bool ffe_post_options PARAMS ((const char **));
 static void ffe_init_options PARAMS ((void));
 static void ffe_print_identifier PARAMS ((FILE *, tree, int));
 
@@ -14050,6 +14051,8 @@ struct language_function GTY(())
 #define LANG_HOOKS_INIT_OPTIONS		ffe_init_options
 #undef  LANG_HOOKS_DECODE_OPTION
 #define LANG_HOOKS_DECODE_OPTION	ffe_decode_option
+#undef  LANG_HOOKS_POST_OPTIONS
+#define LANG_HOOKS_POST_OPTIONS		ffe_post_options
 #undef  LANG_HOOKS_PARSE_FILE
 #define LANG_HOOKS_PARSE_FILE		ffe_parse_file
 #undef  LANG_HOOKS_MARK_ADDRESSABLE
@@ -14115,9 +14118,12 @@ const char *const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
-static const char *
-ffe_init (const char *filename)
+static bool
+ffe_post_options (pfilename)
+     const char **pfilename;
 {
+  const char *filename = *pfilename;
+
   /* Open input file.  */
   if (filename == 0 || !strcmp (filename, "-"))
     {
@@ -14126,9 +14132,17 @@ ffe_init (const char *filename)
     }
   else
     finput = fopen (filename, "r");
+
   if (finput == 0)
     fatal_io_error ("can't open %s", filename);
 
+  return false;
+}
+
+
+static bool
+ffe_init ()
+{
 #ifdef IO_BUFFER_SIZE
   setvbuf (finput, (char *) xmalloc (IO_BUFFER_SIZE), _IOFBF, IO_BUFFER_SIZE);
 #endif
@@ -14144,11 +14158,8 @@ ffe_init (const char *filename)
   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;
+     set the new file name.  Maybe in ffe_post_options.  */
+  return true;
 }
 
 static void
============================================================
Index: gcc/java/lang.c
--- gcc/java/lang.c	24 Feb 2003 02:14:49 -0000	1.121
+++ gcc/java/lang.c	8 Mar 2003 12:59:17 -0000
@@ -53,10 +53,10 @@ struct string_option
   const int on_value;
 };
 
-static const char *java_init (const char *);
+static bool java_init (void);
 static void java_finish (void);
 static void java_init_options (void);
-static bool java_post_options (void);
+static bool java_post_options (const char **);
 
 static int java_decode_option (int, char **);
 static void put_decl_string (const char *, int);
@@ -508,8 +508,8 @@ java_decode_option (int argc __attribute
 /* Global open file.  */
 FILE *finput;
 
-static const char *
-java_init (const char *filename)
+static bool
+java_init (void)
 {
 #if 0
   extern int flag_minimal_debug;
@@ -526,67 +526,6 @@ java_init (const char *filename)
       && force_align_functions_log < 1)
     force_align_functions_log = 1;
 
-  /* Open input file.  */
-
-  if (filename == 0 || !strcmp (filename, "-"))
-    {
-      finput = stdin;
-      filename = "stdin";
-
-      if (dependency_tracking)
-	error ("can't do dependency tracking with input from stdin");
-    }
-  else
-    {
-      if (dependency_tracking)
-	{
-	  char *dot;
-
-	  /* If the target is set and the output filename is set, then
-	     there's no processing to do here.  Otherwise we must
-	     compute one or the other.  */
-	  if (! ((dependency_tracking & DEPEND_TARGET_SET)
-		 && (dependency_tracking & DEPEND_FILE_ALREADY_SET)))
-	    {
-	      dot = strrchr (filename, '.');
-	      if (dot == NULL)
-		error ("couldn't determine target name for dependency tracking");
-	      else
-		{
-		  char *buf = xmalloc (dot - filename +
-				       3 + sizeof (TARGET_OBJECT_SUFFIX));
-		  strncpy (buf, filename, dot - filename);
-
-		  /* If emitting class files, we might have multiple
-		     targets.  The class generation code takes care of
-		     registering them.  Otherwise we compute the
-		     target name here.  */
-		  if ((dependency_tracking & DEPEND_TARGET_SET))
-		    ; /* Nothing.  */
-		  else if (flag_emit_class_files)
-		    jcf_dependency_set_target (NULL);
-		  else
-		    {
-		      strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX);
-		      jcf_dependency_set_target (buf);
-		    }
-
-		  if ((dependency_tracking & DEPEND_FILE_ALREADY_SET))
-		    ; /* Nothing.  */
-		  else if ((dependency_tracking & DEPEND_SET_FILE))
-		    {
-		      strcpy (buf + (dot - filename), ".d");
-		      jcf_dependency_set_dep_file (buf);
-		    }
-		  else
-		    jcf_dependency_set_dep_file ("-");
-
-		  free (buf);
-		}
-	    }
-	}
-    }
-
   jcf_path_init ();
   jcf_path_seal (version_flag);
 
@@ -594,7 +533,7 @@ java_init (const char *filename)
 
   using_eh_for_cleanups ();
 
-  return filename;
+  return true;
 }
 
 static void
@@ -813,8 +752,10 @@ java_can_use_bit_fields_p (void)
 
 /* Post-switch processing.  */
 static bool
-java_post_options (void)
+java_post_options (const char **pfilename)
 {
+  const char *filename = *pfilename;
+
  /* 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)
@@ -825,6 +766,67 @@ java_post_options (void)
 	{
 	  flag_inline_trees = 2;
 	  flag_inline_functions = 0;
+	}
+    }
+
+  /* Open input file.  */
+
+  if (filename == 0 || !strcmp (filename, "-"))
+    {
+      finput = stdin;
+      filename = "stdin";
+
+      if (dependency_tracking)
+	error ("can't do dependency tracking with input from stdin");
+    }
+  else
+    {
+      if (dependency_tracking)
+	{
+	  char *dot;
+
+	  /* If the target is set and the output filename is set, then
+	     there's no processing to do here.  Otherwise we must
+	     compute one or the other.  */
+	  if (! ((dependency_tracking & DEPEND_TARGET_SET)
+		 && (dependency_tracking & DEPEND_FILE_ALREADY_SET)))
+	    {
+	      dot = strrchr (filename, '.');
+	      if (dot == NULL)
+		error ("couldn't determine target name for dependency tracking");
+	      else
+		{
+		  char *buf = xmalloc (dot - filename +
+				       3 + sizeof (TARGET_OBJECT_SUFFIX));
+		  strncpy (buf, filename, dot - filename);
+
+		  /* If emitting class files, we might have multiple
+		     targets.  The class generation code takes care of
+		     registering them.  Otherwise we compute the
+		     target name here.  */
+		  if ((dependency_tracking & DEPEND_TARGET_SET))
+		    ; /* Nothing.  */
+		  else if (flag_emit_class_files)
+		    jcf_dependency_set_target (NULL);
+		  else
+		    {
+		      strcpy (buf + (dot - filename), TARGET_OBJECT_SUFFIX);
+		      jcf_dependency_set_target (buf);
+		    }
+
+		  if ((dependency_tracking & DEPEND_FILE_ALREADY_SET))
+		    ; /* Nothing.  */
+		  else if ((dependency_tracking & DEPEND_SET_FILE))
+		    {
+		      strcpy (buf + (dot - filename), ".d");
+		      jcf_dependency_set_dep_file (buf);
+		    }
+		  else
+		    jcf_dependency_set_dep_file ("-");
+
+		  free (buf);
+		}
+	    }
 	}
     }
 
============================================================
Index: gcc/objc/objc-act.c
--- gcc/objc/objc-act.c	7 Mar 2003 01:20:52 -0000	1.167
+++ gcc/objc/objc-act.c	8 Mar 2003 12:59:18 -0000
@@ -432,13 +432,11 @@ generate_struct_by_value_array ()
   exit (0);
 }
 
-const char *
-objc_init (filename)
-     const char *filename;
+bool
+objc_init ()
 {
-  filename = c_objc_common_init (filename);
-  if (filename == NULL)
-    return filename;
+  if (c_objc_common_init () == false)
+    return false;
 
   /* Force the line number back to 0; check_newline will have
      raised it to 1, which will make the builtin functions appear
@@ -482,7 +480,7 @@ objc_init (filename)
   if (print_struct_values)
     generate_struct_by_value_array ();
 
-  return filename;
+  return true;
 }
 
 void
============================================================
Index: gcc/objc/objc-act.h
--- gcc/objc/objc-act.h	2 Jan 2003 11:39:54 -0000	1.15
+++ gcc/objc/objc-act.h	8 Mar 2003 12:59:19 -0000
@@ -24,7 +24,7 @@ Boston, MA 02111-1307, USA.  */
 
 /*** Public Interface (procedures) ***/
 
-const char *objc_init				PARAMS ((const char *));
+bool objc_init					PARAMS ((void));
 const char *objc_printable_name			PARAMS ((tree, int));
 
 /* used by yyparse */
============================================================
Index: gcc/treelang/tree1.c
--- gcc/treelang/tree1.c	1 Mar 2003 02:05:37 -0000	1.4
+++ gcc/treelang/tree1.c	8 Mar 2003 12:59:19 -0000
@@ -78,7 +78,7 @@ unsigned int option_lexer_trace = 0;
 
 /* Local variables.  */
 
-unsigned char *in_fname = NULL;	/* Input file name.  */
+const char *in_fname;	/* Input file name.  */
 
 /* This is 1 if we have output the version string.  */
 
@@ -179,12 +179,12 @@ treelang_decode_option (num_options_left
 
 /* Language dependent parser setup.  */
 
-const char*
-treelang_init (const char* filename)
+bool
+treelang_init ()
 {
-  /* Set up the declarations needed for this front end.  */
+  in_fname = main_input_filename;
 
-  input_filename = "";
+  /* Set up the declarations needed for this front end.  */
   lineno = 0;
 
   /* Init decls etc.  */
@@ -193,7 +193,7 @@ treelang_init (const char* filename)
 
   /* This error will not happen from GCC as it will always create a
      fake input file.  */
-  if (!filename || (filename[0] == ' ') || (!filename[0])) 
+  if (!in_fname || in_fname[0] == ' ' || !in_fname[0]) 
     {
       if (!version_done)
         {
@@ -201,17 +201,17 @@ treelang_init (const char* filename)
           exit (1);
         }
 
-      in_fname = NULL;
-      return NULL;
+      return false;
     }
-  yyin = fopen (filename, "r");
+
+  yyin = fopen (in_fname, "r");
   if (!yyin)
     {
-      fprintf (stderr, "Unable to open input file %s\n", filename);
+      fprintf (stderr, "Unable to open input file %s\n", in_fname);
       exit (1);
     }
-  input_filename = filename;
-  return (char*) (in_fname = (unsigned char*)filename);
+
+  return true;
 }
 
 /* Language dependent wrapup.  */
============================================================
Index: gcc/treelang/treelang.h
--- gcc/treelang/treelang.h	1 Mar 2003 02:05:37 -0000	1.3
+++ gcc/treelang/treelang.h	8 Mar 2003 12:59:19 -0000
@@ -40,7 +40,7 @@ enum category_enum 
 };
 
 /* Input file name and FILE.  */
-extern unsigned char* in_fname;
+extern const char* in_fname;
 extern FILE* yyin;
 
 /* Forward references to satisfy mutually recursive definitions.  */
============================================================
Index: gcc/treelang/treetree.c
--- gcc/treelang/treetree.c	5 Mar 2003 06:29:01 -0000	1.15
+++ gcc/treelang/treetree.c	8 Mar 2003 12:59:19 -0000
@@ -179,14 +179,14 @@ tree_code_get_type (int type_num)
    LINENO in file FILENAME.  */
 
 void
-tree_code_if_start (tree exp, unsigned char* filename, int lineno)
+tree_code_if_start (tree exp, const char* filename, int lineno)
 {
   tree cond_exp;
   cond_exp = build (NE_EXPR,
                  TREE_TYPE (exp),
                  exp,
                  build1 (CONVERT_EXPR, TREE_TYPE (exp), integer_zero_node));
-  emit_line_note ((const char *)filename, lineno); /* Output the line number information.  */
+  emit_line_note (filename, lineno); /* Output the line number information.  */
   expand_start_cond (cond_exp, /* Exit-able if nonzero.  */ 0);
 }
 
@@ -194,9 +194,9 @@ tree_code_if_start (tree exp, unsigned c
    at line LINENO in file FILENAME.  */
 
 void
-tree_code_if_else (unsigned char* filename, int lineno)
+tree_code_if_else (const char* filename, int lineno)
 {
-  emit_line_note ((const char *)filename, lineno); /* Output the line number information.  */
+  emit_line_note (filename, lineno); /* Output the line number information.  */
   expand_start_else ();
 }
 
@@ -204,9 +204,9 @@ tree_code_if_else (unsigned char* filena
    at line LINENO in file FILENAME.  */
 
 void
-tree_code_if_end (unsigned char* filename, int lineno)
+tree_code_if_end (const char* filename, int lineno)
 {
-  emit_line_note ((const char *)filename, lineno); /* Output the line number information.  */
+  emit_line_note (filename, lineno); /* Output the line number information.  */
   expand_end_cond ();
 }
 
@@ -219,7 +219,7 @@ tree_code_create_function_prototype (uns
                                     unsigned int storage_class,
                                     unsigned int ret_type,
                                     struct prod_token_parm_item* parms,
-                                    unsigned char* filename,
+                                    const char* filename,
                                     int lineno)
 {
 
@@ -252,7 +252,7 @@ tree_code_create_function_prototype (uns
   fn_decl = build_decl (FUNCTION_DECL, id, fn_type);
 
   DECL_CONTEXT (fn_decl) = NULL_TREE; /* Nested functions not supported here.  */
-  DECL_SOURCE_FILE (fn_decl) = (const char *)filename;
+  DECL_SOURCE_FILE (fn_decl) = filename;
  /*  if (lineno > 1000000)
     ; */ /* Probably the line # is rubbish because someone forgot to set
     the line number - and unfortunately impossible line #s are used as
@@ -304,7 +304,7 @@ tree_code_create_function_prototype (uns
     parameter details are in the lists PARMS. Returns nothing.  */
 void
 tree_code_create_function_initial (tree prev_saved,
-                                  unsigned char* filename,
+                                  const char* filename,
                                   int lineno,
                                   struct prod_token_parm_item* parms)
 {
@@ -332,14 +332,14 @@ tree_code_create_function_initial (tree 
   current_function_decl = fn_decl;
   DECL_INITIAL (fn_decl) = error_mark_node;
 
-  DECL_SOURCE_FILE (fn_decl) = (const char *)filename;
+  DECL_SOURCE_FILE (fn_decl) = filename;
   DECL_SOURCE_LINE (fn_decl) = lineno;
 
   /* Prepare creation of rtl for a new function.  */
 
   resultdecl = DECL_RESULT (fn_decl) = build_decl (RESULT_DECL, NULL_TREE, TREE_TYPE (TREE_TYPE (fn_decl)));
   DECL_CONTEXT (DECL_RESULT (fn_decl)) = fn_decl;
-  DECL_SOURCE_FILE (resultdecl) = (const char *)filename;
+  DECL_SOURCE_FILE (resultdecl) = filename;
   DECL_SOURCE_LINE (resultdecl) = lineno;
   /* Work out the size. ??? is this needed.  */
   layout_decl (DECL_RESULT (fn_decl), 0);
@@ -359,7 +359,7 @@ tree_code_create_function_initial (tree 
       if (!fn_decl)
         abort ();
       DECL_CONTEXT (parm_decl) = fn_decl;
-      DECL_SOURCE_FILE (parm_decl) = (const char *)filename;
+      DECL_SOURCE_FILE (parm_decl) = filename;
       DECL_SOURCE_LINE (parm_decl) = lineno;
       parm_list = chainon (parm_decl, parm_list);
     }
@@ -389,7 +389,7 @@ tree_code_create_function_initial (tree 
   make_decl_rtl (fn_decl, NULL);
 
   /* Use filename/lineno from above.  */
-  init_function_start (fn_decl, (const char *)filename, lineno);
+  init_function_start (fn_decl, filename, lineno);
 
   /* Create rtl for startup code of function, such as saving registers.  */
 
@@ -435,12 +435,12 @@ tree_code_create_function_initial (tree 
 
   expand_start_bindings (0);
 
-  emit_line_note ((const char *)filename, lineno); /* Output the line number information.  */
+  emit_line_note (filename, lineno); /* Output the line number information.  */
 }
 
 /* Wrapup a function contained in file FILENAME, ending at line LINENO.  */
 void
-tree_code_create_function_wrapup (unsigned char* filename,
+tree_code_create_function_wrapup (const char* filename,
                                  int lineno)
 {
   tree block;
@@ -448,7 +448,7 @@ tree_code_create_function_wrapup (unsign
 
   fn_decl = current_function_decl;
 
-  emit_line_note ((const char *)filename, lineno); /* Output the line number information.  */
+  emit_line_note (filename, lineno); /* Output the line number information.  */
 
   /* Get completely built level from debugger symbol table.  */
 
@@ -460,7 +460,7 @@ tree_code_create_function_wrapup (unsign
 
   /* Emit rtl for end of function.  */
 
-  expand_function_end ((const char *)filename, lineno, 0);
+  expand_function_end (filename, lineno, 0);
 
   /* Pop the level.  */
 
@@ -498,7 +498,7 @@ tree_code_create_variable (unsigned int 
                                unsigned int length,
                                unsigned int expression_type,
                                tree init,
-                               unsigned char* filename,
+                               const char* filename,
                                int lineno)
 {
   tree var_type;
@@ -531,7 +531,7 @@ tree_code_create_variable (unsigned int 
 
   DECL_CONTEXT (var_decl) = current_function_decl;
 
-  DECL_SOURCE_FILE (var_decl) = (const char *)filename;
+  DECL_SOURCE_FILE (var_decl) = filename;
   DECL_SOURCE_LINE (var_decl) = lineno;
 
   /* Set the storage mode and whether only visible in the same file.  */
@@ -613,10 +613,10 @@ tree_code_generate_return (tree type, tr
 
 void
 tree_code_output_expression_statement (tree code,
-                                       unsigned char* filename, int lineno)
+                                       const char* filename, int lineno)
 {
   /* Output the line number information.  */
-  emit_line_note ((const char *)filename, lineno);
+  emit_line_note (filename, lineno);
   TREE_USED (code) = 1;
   TREE_SIDE_EFFECTS (code) = 1;
   expand_expr_stmt (code);
============================================================
Index: gcc/treelang/treetree.h
--- gcc/treelang/treetree.h	1 Mar 2003 02:05:37 -0000	1.3
+++ gcc/treelang/treetree.h	8 Mar 2003 12:59:19 -0000
@@ -39,31 +39,31 @@ void tree_ggc_storage_always_used  (void
 tree tree_code_get_expression (unsigned int exp_type, tree type, tree op1, tree op2, tree op3);
 tree tree_code_get_numeric_type (unsigned int size1, unsigned int sign1);
 void tree_code_create_function_initial (tree prev_saved,
-                                       unsigned char* filename, int lineno,
+                                       const char* filename, int lineno,
                                        struct prod_token_parm_item* parms);
-void tree_code_create_function_wrapup (unsigned char* filename, int lineno);
+void tree_code_create_function_wrapup (const char* filename, int lineno);
 tree tree_code_create_function_prototype (unsigned char* chars,
                                          unsigned int storage_class,
                                          unsigned int ret_type,
                                          struct prod_token_parm_item* parms,                                 
-                                         unsigned char* filename,
+                                         const char* filename,
                                          int lineno);
 tree tree_code_create_variable (unsigned int storage_class,
                                unsigned char* chars,
                                unsigned int length,
                                unsigned int expression_type,
                                tree init,
-                               unsigned char* filename,
+                               const char* filename,
                                int lineno);
-void tree_code_output_expression_statement (tree code, unsigned char* filename, int lineno);
+void tree_code_output_expression_statement (tree code, const char* filename, int lineno);
 tree get_type_for_numeric_type (unsigned int numeric_type);
-void tree_code_if_start (tree exp, unsigned char* filename, int lineno);
-void tree_code_if_else (unsigned char* filename, int lineno);
-void tree_code_if_end (unsigned char* filename, int lineno);
+void tree_code_if_start (tree exp, const char* filename, int lineno);
+void tree_code_if_else (const char* filename, int lineno);
+void tree_code_if_end (const char* filename, int lineno);
 tree tree_code_get_type (int type_num);
 void treelang_init_decl_processing (void);
 void treelang_finish (void);
-const char *treelang_init (const char* filename);
+bool treelang_init (void);
 int treelang_decode_option (int, char **);
 void treelang_parse_file (int debug_flag);
 void push_var_level (void);


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