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]

Re: [3.4 patch?] -save-temps still produces different .s and .o


On Jan 20, 2004, Alexandre Oliva <aoliva@redhat.com> wrote:

> On Jan 20, 2004, Alexandre Oliva <aoliva@redhat.com> wrote:
>> I'll look a bit more into how to overcome this problem.

> I really don't see how to overcome it without moving the calls of
> lang_depend_init and init_final (and coverage_init?) into parse_file
> hooks, as I suggested before.

Here's a patch for mainline that fixes some details in the patch you
posted earlier, and introduces the change above, such that
bootstrapping with distcc using both localhost and remote machines now
passes the compare test.  Yay!

The main detail that I had to fix in your patch was to maintain the
property that pre-processing an already preprocessed file should print
the same header.  With your patch, the directory name ended up being
printed twice in a command line like this:

gcc -E -g foo.c | gcc -E -fpreprocessed -


I've also added an LC_RENAME to the main input file after the
directory name, just in case we choose to not print the <builtin> at
<command-line> LC_RENAMEs at some point.  I'm not attached to this
change, so I could take it out if people would prefer.

> We could then trade the lang_depend_init hook for an init parameter
> to the parse_file hook,

Getting rid of lang_depend_init is possible, but it would make it more
difficult for C, C++ and ObjC to share the same parse_file hook.
Still, I didn't find this change to be a major maintenance hurdle.

Bootstrapping (almost done) and regression-testing mainline on
i686-pc-linux-gnu.  Ok to install if it passes?

How about the 3.4 branch?  We should really do something about the 3.4
branch ASAP: either fix -fworking-directory with something like the
patch below, or take it out.  It would be a shame to release 3.4 with
a new feature already broken.  The only change that doesn't apply
there is the one that removes const from cpp_get_line_maps, since the
branch doesn't have the const there.

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>, Per Bothner <per@bothner.com>

	Partially revert/redo 2003-10-01 change; fix -fworking-directory.
	Emit initial .file directive with real main input file.
	* c-common.h (c_common_parse_file): Adjust.
	* c-opts.c (finish_options): Remove input file argument.  Adjust
	all callers.  Do LC_RENAME for <built-in>.  Move opening of input
	file...
	(c_common_parse_file): ... here.  Take init function and pointer
	to main input file pointer as arguments.  Call init function after
	opening first input file.
	(push_command_line_include): Don't cpp_push_main_file.  
	Do LC_RENAME rathe than LC_LEAVE to get back to main file.
	Compared to pre-10-01 version, inline cpp_rename_to_main_file.
	Set  tracing of includes depending on options.
	* cppinit.c (cpp_find_main_file, cpp_push_main_file): Merge back to
	(cpp_read_main_file): as before 10-01.  Call _cpp_stack_file.
	* cpplib.c (cpp_get_line_maps): Don't return pointer to const.
	* cpplib.h: Update declarations to match.
	* fix-header.c (read_scan_file): Call cpp_read_main_file instead
	of cpp_find_main_file + cpp_push_main_file.
	* langhooks.c (lhd_parse_file): New.
	* langhooks-def.h (lhd_parse_file): Declare.
	(LANG_HOOKS_PARSE_FILE): Use it.
	* langhooks.h (lang_hooks): Add to parse_file type parameters for
	init function and pointer to main input file pointer.  Change
	return type to bool.
	* toplev.c (compile_file): Pass lang_dependent_init to the
	parse_file hook; if it returns false, don't finish compilation.
	Move init calls...
	(lang_dependent_init): ... here.  Change return type to bool.
	(do_compile): Don't call lang_dependent_init.

Index: gcc/c-common.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-common.h,v
retrieving revision 1.217
diff -u -p -r1.217 c-common.h
--- gcc/c-common.h 21 Jan 2004 20:39:51 -0000 1.217
+++ gcc/c-common.h 23 Jan 2004 02:12:19 -0000
@@ -964,7 +964,8 @@ extern unsigned int c_common_init_option
 extern bool c_common_post_options (const char **);
 extern bool c_common_init (void);
 extern void c_common_finish (void);
-extern void c_common_parse_file (int);
+extern bool c_common_parse_file (int, bool (*init)(const char *),
+				 const char **);
 extern HOST_WIDE_INT c_common_get_alias_set (tree);
 extern void c_register_builtin_type (tree, const char*);
 extern bool c_promoting_integer_type_p (tree);
Index: gcc/c-opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/c-opts.c,v
retrieving revision 1.98
diff -u -p -r1.98 c-opts.c
--- gcc/c-opts.c 21 Jan 2004 20:39:51 -0000 1.98
+++ gcc/c-opts.c 23 Jan 2004 02:12:20 -0000
@@ -108,7 +108,7 @@ static void sanitize_cpp_opts (void);
 static void add_prefixed_path (const char *, size_t);
 static void push_command_line_include (void);
 static void cb_file_change (cpp_reader *, const struct line_map *);
-static bool finish_options (const char *);
+static bool finish_options (void);
 
 #ifndef STDC_0_IN_SYSTEM_HEADERS
 #define STDC_0_IN_SYSTEM_HEADERS 0
@@ -1172,7 +1172,7 @@ c_common_init (void)
 
   if (flag_preprocess_only)
     {
-      if (finish_options (in_fnames[0]))
+      if (finish_options ())
 	preprocess_file (parse_in);
       return false;
     }
@@ -1185,10 +1185,13 @@ c_common_init (void)
 
 /* Initialize the integrated preprocessor after debug output has been
    initialized; loop over each input file.  */
-void
-c_common_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
+bool
+c_common_parse_file (int set_yydebug ATTRIBUTE_UNUSED,
+		     bool (*init)(const char *),
+		     const char **main_input_file_p)
 {
   unsigned file_index;
+  bool first = true;
   
 #if YYDEBUG != 0
   yydebug = set_yydebug;
@@ -1200,6 +1203,8 @@ c_common_parse_file (int set_yydebug ATT
   
   do
     {
+      const char *tif = in_fnames[file_index];
+
       if (file_index > 0)
 	{
 	  /* Reset the state of the parser.  */
@@ -1209,17 +1214,30 @@ c_common_parse_file (int set_yydebug ATT
 	  cpp_undef_all (parse_in);
 	}
 
-      if (! finish_options(in_fnames[file_index]))
+      this_input_filename = tif;
+
+      if (! (tif = cpp_read_main_file (parse_in, this_input_filename)))
+	continue;
+
+      *main_input_file_p = tif;
+
+      if (first && !init (tif))
+	return false;
+
+      if (! finish_options ())
 	break;
-      if (file_index == 0)
+      if (first)
 	pch_init();
       c_parse_file ();
 
       file_index++;
+      first = false;
     } while (file_index < num_in_fnames);
   
   free_parser_stacks ();
   finish_file ();
+
+  return true;
 }
 
 /* Common finish hook for the C, ObjC and C++ front ends.  */
@@ -1379,17 +1397,13 @@ add_prefixed_path (const char *suffix, s
    TIF is the input file to which we will return after processing all
    the includes.  Returns true on success.  */
 static bool
-finish_options (const char *tif)
+finish_options (void)
 {
-  this_input_filename = tif;
-  if (! cpp_find_main_file (parse_in, this_input_filename))
-    return false;
-
   if (!cpp_opts->preprocessed)
     {
       size_t i;
 
-      cpp_change_file (parse_in, LC_ENTER, _("<built-in>"));
+      cpp_change_file (parse_in, LC_RENAME, _("<built-in>"));
       cpp_init_builtins (parse_in, flag_hosted);
       c_cpp_builtins (parse_in);
 
@@ -1458,12 +1472,16 @@ push_command_line_include (void)
   if (include_cursor == deferred_count)
     {
       include_cursor++;
-      /* Restore the line map from <command line>.  */
-      if (! cpp_opts->preprocessed)
-	cpp_change_file (parse_in, LC_LEAVE, NULL);
       /* -Wunused-macros should only warn about macros defined hereafter.  */
       cpp_opts->warn_unused_macros = warn_unused_macros;
-      cpp_push_main_file (parse_in);
+      /* Restore the line map from <command line>.  */
+      if (! cpp_opts->preprocessed)
+	cpp_change_file (parse_in, LC_RENAME, main_input_filename);
+
+      /* Set this here so the client can change the option if it wishes,
+	 and after stacking the main file so we don't trace the main file.  */
+      cpp_get_line_maps (parse_in)->trace_includes
+	= cpp_opts->print_include_names;
     }
 }
 
Index: gcc/cppinit.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cppinit.c,v
retrieving revision 1.300
diff -u -p -r1.300 cppinit.c
--- gcc/cppinit.c 21 Jan 2004 20:39:52 -0000 1.300
+++ gcc/cppinit.c 23 Jan 2004 02:12:21 -0000
@@ -453,9 +453,10 @@ cpp_post_options (cpp_reader *pfile)
 }
 
 /* Setup for processing input from the file named FNAME, or stdin if
-   it is the empty string.  Returns true if the file was found.  */
-bool
-cpp_find_main_file (cpp_reader *pfile, const char *fname)
+   it is the empty string.  Return the original filename
+   on success (e.g. foo.i->foo.c), or NULL on failure.  */
+const char *
+cpp_read_main_file (cpp_reader *pfile, const char *fname)
 {
   if (CPP_OPTION (pfile, deps.style) != DEPS_NONE)
     {
@@ -471,8 +472,20 @@ cpp_find_main_file (cpp_reader *pfile, c
   if (_cpp_find_failed (pfile->main_file))
     return false;
 
+  _cpp_stack_file (pfile, pfile->main_file, false);
+  pfile->line++;
+
+  /* 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);
+      fname = pfile->map->to_file;
+    }
+  
   if (CPP_OPTION (pfile, working_directory))
     {
+      const char *name = pfile->map->to_file;
       const char *dir = getpwd ();
       char *dir_with_slashes = alloca (strlen (dir) + 3);
 
@@ -481,27 +494,16 @@ cpp_find_main_file (cpp_reader *pfile, c
 
       if (pfile->cb.dir_change)
 	pfile->cb.dir_change (pfile, dir);
-    }
-  return true;
-}
 
-/* This function reads the file, but does not start preprocessing.
-   This will generate at least one file change callback, and possibly
-   a line change callback.  */
-void
-cpp_push_main_file (cpp_reader *pfile)
-{
-  _cpp_stack_file (pfile, pfile->main_file, false);
-
-  /* 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);
-
-  /* Set this here 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_table->trace_includes = CPP_OPTION (pfile, print_include_names);
+      /* Emit file renames that will be recognized by
+	 read_directory_filename, since dir_change doesn't output
+	 anything when preprocessing (and it shouldn't, otherwise
+	 re-preprocessing would duplicate the directory entry
+	 line).  */
+      _cpp_do_file_change (pfile, LC_RENAME, dir_with_slashes, 1, 0);
+      _cpp_do_file_change (pfile, LC_RENAME, name, 1, 0);
+    }
+  return fname;
 }
 
 /* For preprocessed files, if the first tokens are of the form # NUM.
Index: gcc/cpplib.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.c,v
retrieving revision 1.358
diff -u -p -r1.358 cpplib.c
--- gcc/cpplib.c 21 Jan 2004 20:39:53 -0000 1.358
+++ gcc/cpplib.c 23 Jan 2004 02:12:22 -0000
@@ -1904,7 +1904,7 @@ cpp_get_callbacks (cpp_reader *pfile)
 }
 
 /* The line map set.  */
-const struct line_maps *
+struct line_maps *
 cpp_get_line_maps (cpp_reader *pfile)
 {
   return pfile->line_table;
Index: gcc/cpplib.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cpplib.h,v
retrieving revision 1.273
diff -u -p -r1.273 cpplib.h
--- gcc/cpplib.h 21 Jan 2004 20:39:53 -0000 1.273
+++ gcc/cpplib.h 23 Jan 2004 02:12:22 -0000
@@ -532,18 +532,16 @@ extern void cpp_set_include_chains (cpp_
    through the pointer returned from cpp_get_callbacks, or set them
    with cpp_set_callbacks.  */
 extern cpp_options *cpp_get_options (cpp_reader *);
-extern const struct line_maps *cpp_get_line_maps (cpp_reader *);
+extern struct line_maps *cpp_get_line_maps (cpp_reader *);
 extern cpp_callbacks *cpp_get_callbacks (cpp_reader *);
 extern void cpp_set_callbacks (cpp_reader *, cpp_callbacks *);
 
-/* This function finds the main file, but does not start reading it.
-   Returns true iff the file was found.  */
-extern bool cpp_find_main_file (cpp_reader *, const char *);
-
-/* This function reads the file, but does not start preprocessing.
-   This will generate at least one file change callback, and possibly
-   a line change callback.  */
-extern void cpp_push_main_file (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. */
+extern const char *cpp_read_main_file (cpp_reader *, const char *);
 
 /* Set up built-ins like __FILE__.  */
 extern void cpp_init_builtins (cpp_reader *, int);
Index: gcc/fix-header.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fix-header.c,v
retrieving revision 1.106
diff -u -p -r1.106 fix-header.c
--- gcc/fix-header.c 21 Jan 2004 20:39:54 -0000 1.106
+++ gcc/fix-header.c 23 Jan 2004 02:12:23 -0000
@@ -606,9 +606,8 @@ read_scan_file (char *in_fname, int argc
   options->inhibit_errors = 1;
   cpp_post_options (scan_in);
 
-  if (!cpp_find_main_file (scan_in, in_fname))
+  if (!cpp_read_main_file (scan_in, in_fname))
     exit (FATAL_EXIT_CODE);
-  cpp_push_main_file (scan_in);
 
   cpp_change_file (scan_in, LC_RENAME, "<built-in>");
   cpp_init_builtins (scan_in, true);
Index: gcc/langhooks-def.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks-def.h,v
retrieving revision 1.72
diff -u -p -r1.72 langhooks-def.h
--- gcc/langhooks-def.h 21 Jan 2004 20:40:02 -0000 1.72
+++ gcc/langhooks-def.h 23 Jan 2004 02:12:24 -0000
@@ -43,6 +43,7 @@ extern void lhd_do_nothing (void);
 extern void lhd_do_nothing_t (tree);
 extern void lhd_do_nothing_i (int);
 extern void lhd_do_nothing_f (struct function *);
+extern bool lhd_parse_file (int, bool (*)(const char *), const char **);
 extern bool lhd_post_options (const char **);
 extern HOST_WIDE_INT lhd_get_alias_set (tree);
 extern tree lhd_return_tree (tree);
@@ -92,7 +93,7 @@ extern tree lhd_callgraph_analyze_expr (
 #define LANG_HOOKS_IDENTIFIER_SIZE	sizeof (struct lang_identifier)
 #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_PARSE_FILE		lhd_parse_file
 #define LANG_HOOKS_CLEAR_BINDING_STACK	lhd_clear_binding_stack
 #define LANG_HOOKS_INIT_OPTIONS		hook_uint_uint_constcharptrptr_0
 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics
Index: gcc/langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.58
diff -u -p -r1.58 langhooks.c
--- gcc/langhooks.c 21 Jan 2004 20:40:02 -0000 1.58
+++ gcc/langhooks.c 23 Jan 2004 02:12:24 -0000
@@ -105,6 +105,18 @@ lhd_post_options (const char **pfilename
   return false;
 }
 
+/* The default parse file hook.  */
+bool
+lhd_parse_file (int set_yydebug ATTRIBUTE_UNUSED,
+		bool (*init)(const char *) ATTRIBUTE_UNUSED,
+		const char **main_input_file_p ATTRIBUTE_UNUSED)
+{
+  if (!init (*main_input_file_p))
+    return false;
+
+  return true;
+}
+
 /* Called from by print-tree.c.  */
 
 void
Index: gcc/langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.79
diff -u -p -r1.79 langhooks.h
--- gcc/langhooks.h 21 Jan 2004 20:40:02 -0000 1.79
+++ gcc/langhooks.h 23 Jan 2004 02:12:24 -0000
@@ -267,7 +267,7 @@ struct lang_hooks
 
   /* Parses the entire file.  The argument is nonzero to cause bison
      parsers to dump debugging information during parsing.  */
-  void (*parse_file) (int);
+  bool (*parse_file) (int, bool (*)(const char *), const char **);
 
   /* Called immediately after parsing to clear the binding stack.  */
   void (*clear_binding_stack) (void);
Index: gcc/toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.867
diff -u -p -r1.867 toplev.c
--- gcc/toplev.c 20 Jan 2004 22:08:16 -0000 1.867
+++ gcc/toplev.c 23 Jan 2004 02:12:27 -0000
@@ -112,7 +112,7 @@ static void general_init (const char *);
 static void do_compile (void);
 static void process_options (void);
 static void backend_init (void);
-static int lang_dependent_init (const char *);
+static bool lang_dependent_init (const char *);
 static void init_asm_output (const char *);
 static void finalize (void);
 
@@ -1794,16 +1794,14 @@ pop_srcloc (void)
 static void
 compile_file (void)
 {
-  /* Initialize yet another pass.  */
-
-  init_final (main_input_filename);
-  coverage_init (aux_base_name);
+  int full_compile;
 
   timevar_push (TV_PARSE);
 
   /* Call the parser, which parses the entire file (calling
      rest_of_compilation for each function).  */
-  (*lang_hooks.parse_file) (set_yydebug);
+  full_compile = (*lang_hooks.parse_file) (set_yydebug, &lang_dependent_init,
+					   &main_input_filename);
 
   /* In case there were missing block closers,
      get us back to the global binding level.  */
@@ -1813,7 +1811,7 @@ compile_file (void)
      what's left of the symbol table output.  */
   timevar_pop (TV_PARSE);
 
-  if (flag_syntax_only)
+  if (!full_compile || flag_syntax_only)
     return;
 
   (*lang_hooks.decls.final_write_globals)();
@@ -4496,7 +4494,7 @@ backend_init (void)
 }
 
 /* Language-dependent initialization.  Returns nonzero on success.  */
-static int
+static bool
 lang_dependent_init (const char *name)
 {
   if (dump_base_name == 0)
@@ -4504,7 +4502,7 @@ lang_dependent_init (const char *name)
 
   /* Other front-end initialization.  */
   if ((*lang_hooks.init) () == 0)
-    return 0;
+    return false;
 
   init_asm_output (name);
 
@@ -4534,7 +4532,12 @@ lang_dependent_init (const char *name)
 
   timevar_pop (TV_SYMOUT);
 
-  return 1;
+  /* Initialize yet another pass.  */
+
+  init_final (name);
+  coverage_init (aux_base_name);
+
+  return true;
 }
 
 /* Clean up: close opened files, etc.  */
@@ -4615,24 +4618,20 @@ do_compile (void)
       if (!no_backend)
 	backend_init ();
 
-      /* Language-dependent initialization.  Returns true on success.  */
-      if (lang_dependent_init (main_input_filename))
+      if (flag_unit_at_a_time)
 	{
-	  if (flag_unit_at_a_time)
-	    {
-	      open_dump_file (DFI_cgraph, NULL);
-	      cgraph_dump_file = rtl_dump_file;
-	      rtl_dump_file = NULL;
-	    }
+	  open_dump_file (DFI_cgraph, NULL);
+	  cgraph_dump_file = rtl_dump_file;
+	  rtl_dump_file = NULL;
+	}
 
-	  compile_file ();
+      compile_file ();
 
-	  if (flag_unit_at_a_time)
-	    {
-	      rtl_dump_file = cgraph_dump_file;
-	      cgraph_dump_file = NULL;
-              close_dump_file (DFI_cgraph, NULL, NULL_RTX);
-	    }
+      if (flag_unit_at_a_time)
+	{
+	  rtl_dump_file = cgraph_dump_file;
+	  cgraph_dump_file = NULL;
+	  close_dump_file (DFI_cgraph, NULL, NULL_RTX);
 	}
 
       finalize ();
Index: gcc/ada/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* misc.c (gnat_parse_file): Take init function and pointer
	to main input file pointer as arguments.  Call init function after
	opening first input file.

Index: gcc/ada/misc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/misc.c,v
retrieving revision 1.75
diff -u -p -r1.75 misc.c
--- gcc/ada/misc.c 12 Jan 2004 12:56:39 -0000 1.75
+++ gcc/ada/misc.c 23 Jan 2004 02:13:34 -0000
@@ -95,7 +95,8 @@ static void gnat_print_type		(FILE *, tr
 static const char *gnat_printable_name	(tree, int);
 static tree gnat_eh_runtime_type	(tree);
 static int gnat_eh_type_covers		(tree, tree);
-static void gnat_parse_file		(int);
+static bool gnat_parse_file		(int, bool (*)(const char *),
+					 const char **);
 static rtx gnat_expand_expr		(tree, rtx, enum machine_mode, int,
 					 rtx *);
 static void internal_error_function	(const char *, va_list *);
@@ -207,9 +208,13 @@ extern void _ada_gnat1drv	(void);
 
 /* The parser for the language.  For us, we process the GNAT tree.  */
 
-static void
-gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
+static bool
+gnat_parse_file (int set_yydebug ATTRIBUTE_UNUSED,
+		 bool (*init)(const char *), const char **main_input_file_p)
 {
+  if (!init (*main_input_file_p))
+    return false;
+  
   /* call the target specific initializations */
   __gnat_initialize();
 
@@ -220,6 +225,8 @@ gnat_parse_file (int set_yydebug ATTRIBU
 
   /* Call the front end */
   _ada_gnat1drv ();
+
+  return true;
 }
 
 /* Decode all the language specific options that cannot be decoded by GCC.
Index: gcc/f/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* parse.c (ffe_parse_file): Take init function and pointer to main
	input file pointer as arguments.  Call init function after opening
	first input file.
	* com.h (ffe_parse_file): Adjust.

Index: gcc/f/com.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/com.h,v
retrieving revision 1.32
diff -u -p -r1.32 com.h
--- gcc/f/com.h 7 Jan 2004 22:24:40 -0000 1.32
+++ gcc/f/com.h 23 Jan 2004 02:13:41 -0000
@@ -267,7 +267,7 @@ tree ffecom_truth_value (tree expr);
 tree ffecom_truth_value_invert (tree expr);
 tree ffecom_type_expr (ffebld expr);
 tree ffecom_which_entrypoint_decl (void);
-void ffe_parse_file (int);
+bool ffe_parse_file (int, bool (*)(const char *), const char **);
 
 /* Define macros. */
 
Index: gcc/f/parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/f/parse.c,v
retrieving revision 1.14
diff -u -p -r1.14 parse.c
--- gcc/f/parse.c 12 Jan 2003 02:32:39 -0000 1.14
+++ gcc/f/parse.c 23 Jan 2004 02:13:41 -0000
@@ -1,5 +1,5 @@
 /* GNU Fortran
-   Copyright (C) 1995 Free Software Foundation, Inc.
+   Copyright (C) 1995, 2004 Free Software Foundation, Inc.
    Contributed by James Craig Burley.
 
 This file is part of GNU Fortran.
@@ -28,11 +28,15 @@ the Free Software Foundation, 59 Temple 
 
 extern FILE *finput;
 
-void
-ffe_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
+bool
+ffe_parse_file (int set_yydebug ATTRIBUTE_UNUSED,
+		bool (*init)(const char *), const char **main_input_file_p)
 {
   ffewhereFile wf;
 
+  if (!init (*main_input_file_p))
+    return false;
+
   if (ffe_is_version ())
     fprintf (stderr, "GNU Fortran Front End version %s\n", version_string);
 
@@ -44,4 +48,6 @@ ffe_parse_file (int set_yydebug ATTRIBUT
   ffe_file (wf, finput);
 
   ffecom_finish_compile ();
+
+  return true;
 }
Index: gcc/java/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* jcf-parse.c (java_parse_file): Take init function and pointer to
	main input file pointer as arguments.  Call init function after
	opening first input file.
	* java-tree.h (java_parse_file): Adjust.

Index: gcc/java/java-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/java-tree.h,v
retrieving revision 1.194
diff -u -p -r1.194 java-tree.h
--- gcc/java/java-tree.h 16 Jan 2004 17:11:08 -0000 1.194
+++ gcc/java/java-tree.h 23 Jan 2004 02:13:56 -0000
@@ -1119,7 +1119,7 @@ struct lang_type GTY(())
 #define SEARCH_SUPER          2
 #define SEARCH_VISIBLE        4
 
-extern void java_parse_file (int);
+extern bool java_parse_file (int, bool (*)(const char *), const char **);
 extern bool java_mark_addressable (tree);
 extern tree java_type_for_mode (enum machine_mode, int);
 extern tree java_type_for_size (unsigned int, int);
Index: gcc/java/jcf-parse.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/jcf-parse.c,v
retrieving revision 1.157
diff -u -p -r1.157 jcf-parse.c
--- gcc/java/jcf-parse.c 16 Jan 2004 17:11:08 -0000 1.157
+++ gcc/java/jcf-parse.c 23 Jan 2004 02:13:57 -0000
@@ -867,14 +867,18 @@ predefined_filename_p (tree node)
   return 0;
 }
 
-void
-java_parse_file (int set_yydebug ATTRIBUTE_UNUSED)
+bool
+java_parse_file (int set_yydebug ATTRIBUTE_UNUSED,
+		 bool (*init)(const char *), const char **main_input_file_p)
 {
   int filename_count = 0;
   char *list, *next;
   tree node;
   FILE *finput = NULL;
 
+  if (!init (*main_input_file_p))
+    return false;
+
   if (flag_filelist_file)
     {
       int avail = 2000;
@@ -1006,7 +1010,7 @@ java_parse_file (int set_yydebug ATTRIBU
       resource_filename = IDENTIFIER_POINTER (TREE_VALUE (current_file_list));
       compile_resource_file (resource_name, resource_filename);
 
-      return;
+      return true;
     }
 
   current_jcf = main_jcf;
@@ -1122,6 +1126,8 @@ java_parse_file (int set_yydebug ATTRIBU
     }
 
   write_resource_constructor ();
+
+  return true;
 }
 
 /* Return the name of the class corresponding to the name of the file
Index: gcc/treelang/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* tree1.c (treelang_parse_file): Take init function and pointer to
	main input file pointer as arguments.  Call init function after
	opening first input file.
	* treetree.h (treelang_parse_file): Adjust.

Index: gcc/treelang/tree1.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/tree1.c,v
retrieving revision 1.16
diff -u -p -r1.16 tree1.c
--- gcc/treelang/tree1.c 28 Jul 2003 04:39:29 -0000 1.16
+++ gcc/treelang/tree1.c 23 Jan 2004 02:14:04 -0000
@@ -3,7 +3,8 @@
     TREELANG Compiler almost main (tree1)
     Called by GCC's toplev.c
 
-    Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+    Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003,
+    2004 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify it
     under the terms of the GNU General Public License as published by the
@@ -180,11 +181,18 @@ treelang_finish (void)
 
 /* Parse a file.  Debug flag doesn't seem to work. */
 
-void
-treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED)
+bool
+treelang_parse_file (int debug_flag ATTRIBUTE_UNUSED,
+		     bool (*init)(const char *),
+		     const char **main_input_file_p)
 {
+  if (!init (*main_input_file_p))
+    return false;
+  
   treelang_debug ();
   yyparse ();
+
+  return true;
 }
 
 /* Allocate SIZE bytes and clear them.  Not to be used for strings
Index: gcc/treelang/treetree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/treelang/treetree.h,v
retrieving revision 1.8
diff -u -p -r1.8 treetree.h
--- gcc/treelang/treetree.h 2 Jul 2003 20:15:46 -0000 1.8
+++ gcc/treelang/treetree.h 23 Jan 2004 02:14:04 -0000
@@ -3,7 +3,8 @@
     TREELANG Compiler definitions for interfacing to treetree.c
     (compiler back end interface).
 
-    Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+    Copyright (C) 1986, 87, 89, 92-96, 1997, 1999, 2000, 2001, 2002, 2003,
+    2004 Free Software Foundation, Inc.
 
     This program is free software; you can redistribute it and/or modify it
     under the terms of the GNU General Public License as published by the
@@ -65,7 +66,8 @@ void treelang_finish (void);
 bool treelang_init (void);
 unsigned int treelang_init_options (unsigned int, const char **);
 int treelang_handle_option (size_t scode, const char *arg, int value);
-void treelang_parse_file (int debug_flag);
+bool treelang_parse_file (int debug_flag, bool (*)(const char *),
+			  const char**);
 void push_var_level (void);
 void pop_var_level (void);
 const char* get_string (const char *s, size_t l);
-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Happy GNU Year!                     oliva@{lsd.ic.unicamp.br, gnu.org}
Red Hat GCC Developer                 aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist                Professional serial bug killer

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