]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Makefile.in (c-parse.o, c-common.o): Update dependencies.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sun, 18 Nov 2001 11:04:53 +0000 (11:04 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 18 Nov 2001 11:04:53 +0000 (11:04 +0000)
* Makefile.in (c-parse.o, c-common.o): Update dependencies.
* c-common.c: Include diagnostic.h.
(c_common_finish): New.
* c-common.h (c_common_finish): New.
* c-lang.c (LANG_HOOKS_FINISH): Override.
* c-parse.in: Don't include diagnostic.h.
(finish_parse): Remove.
* langhooks.h: Update comments.
* toplev.c (lang_dependent_init): New prototype.
(finalize): New.
(compile_file): Split cleanup code out to finalize.
(lang_dependent_init): Stop if lang_hooks.init fails.
(toplev_main): Update.
* tree.h (finish_parse): Remove.

ada: * misc.c (gnat_decode_option, gnat_init_options): Make definitions
static too.
(gnat_init): Don't return NULL.
(finish_parse): Remove.
cp: * lex.c (cxx_finish): Call c_common_finish.
(finish_parse): Remove.
f: * com.c (finish_parse): Remove.
(ffe_finish): Move body of finish_parse.
java: * lang.c (finish_parse): Rename to java_finish.
(LANG_HOOKS_FINISH, java_finish): New.
objc: * objc-act.c (LANG_HOOKS_FINISH): Override.

From-SVN: r47141

17 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/misc.c
gcc/c-common.c
gcc/c-common.h
gcc/c-lang.c
gcc/c-parse.in
gcc/cp/ChangeLog
gcc/cp/lex.c
gcc/f/ChangeLog
gcc/f/com.c
gcc/java/ChangeLog
gcc/java/lang.c
gcc/langhooks.h
gcc/objc/objc-act.c
gcc/toplev.c
gcc/tree.h

index 90b232c64a927a115e5ecfa6ab35f8e74a859165..f7ff9539db89862f9890ff61655ce89e6832c514 100644 (file)
@@ -1,3 +1,22 @@
+2001-11-18  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * Makefile.in (c-parse.o, c-common.o): Update dependencies.
+       * c-common.c: Include diagnostic.h.
+       (c_common_finish): New.
+       * c-common.h (c_common_finish): New.
+       * c-lang.c (LANG_HOOKS_FINISH): Override.
+       * c-parse.in: Don't include diagnostic.h.
+       (finish_parse): Remove.
+       * langhooks.h: Update comments.
+       * toplev.c (lang_dependent_init): New prototype.
+       (finalize): New.
+       (compile_file): Split cleanup code out to finalize.
+       (lang_dependent_init): Stop if lang_hooks.init fails.
+       (toplev_main): Update.
+       * tree.h (finish_parse): Remove.
+objc:
+       * objc-act.c (LANG_HOOKS_FINISH): Override.
+
 Sat Nov 17 23:30:44 2001  Douglas B. Rupp  <rupp@gnat.com>
 
        * config/alpha/t-vms (LIB2FUNCS_EXTRA): Add vms_tramp.asm.
index b5a7745b7dae13a68b69268079a318003e88b41a..0bd159ce95becfc7898396d7b3cade254a03539d 100644 (file)
@@ -1,3 +1,10 @@
+2001-11-18  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * misc.c (gnat_decode_option, gnat_init_options): Make definitions
+       static too.
+       (gnat_init): Don't return NULL.
+       (finish_parse): Remove.
+
 2001-11-17  Laurent Guerby  <guerby@acm.org>
 
        * Make-lang.in (GNATLIBFLAGS): Add -W -Wall.
index 0ea1339be619d25a7f4c53c3fb59f8d03ff9a2b9..16e3e8ce24d58fea5ee4571158b6974ee27cd495 100644 (file)
@@ -6,7 +6,7 @@
  *                                                                          *
  *                           C Implementation File                          *
  *                                                                          *
- *                             $Revision: 1.11 $
+ *                             $Revision: 1.12 $
  *                                                                          *
  *          Copyright (C) 1992-2001 Free Software Foundation, Inc.          *
  *                                                                          *
@@ -192,7 +192,7 @@ yyparse ()
    it cannot decode. This routine returns 1 if it is successful, otherwise
    it returns 0. */
 
-int
+static int
 gnat_decode_option (argc, argv)
      int argc ATTRIBUTE_UNUSED;
      char **argv;
@@ -251,7 +251,7 @@ gnat_decode_option (argc, argv)
 
 /* Initialize for option processing.  */
 
-void
+static void
 gnat_init_options ()
 {
   /* Initialize gnat_argv with save_argv size */
@@ -394,6 +394,9 @@ gnat_init (filename)
   dwarf2out_set_demangle_name_func (convert_ada_name_to_qualified_name);
 #endif
 
+  if (filename == 0)
+    filename = "";
+
   return filename;
 }
 
@@ -879,11 +882,6 @@ insert_code_for (gnat_node)
     }
 }
 
-void
-finish_parse ()
-{
-}
-
 #if 0
 
 /* Return the alignment for GNAT_TYPE.  */
index 6b6b36b720fa6af646c1e237d3506b2a02341a65..dde1af3b892f93ffe4b36af92e67be04b71d70d6 100644 (file)
@@ -30,6 +30,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "ggc.h"
 #include "expr.h"
 #include "c-common.h"
+#include "diagnostic.h"
 #include "tm_p.h"
 #include "obstack.h"
 #include "c-lex.h"
@@ -3889,6 +3890,17 @@ c_common_lang_init (filename)
   return filename;
 }
 
+/* Common finish hook for the C, ObjC and C++ front ends.  */
+void
+c_common_finish ()
+{
+  cpp_finish (parse_in);
+
+  /* For performance, avoid tearing down cpplib's internal structures.
+     Call cpp_errors () instead of cpp_destroy ().  */
+  errorcount += cpp_errors (parse_in);
+}
+
 static void
 c_init_attributes ()
 {
index df6cd9d387fe492741f626cb81ef7ab2472af1b9..7ccaef7ee8f83215ff3cabd38473d8e8f31c105c 100644 (file)
@@ -543,6 +543,7 @@ extern void disable_builtin_function                PARAMS ((const char *));
 extern tree build_va_arg                       PARAMS ((tree, tree));
 
 extern const char *c_common_lang_init          PARAMS ((const char *));
+extern void c_common_finish                    PARAMS ((void));
 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 5655d8cfcdffa4946d29fdea23209ae8ac83e858..5a82c59ecdb4db61a5184ba2487f7dc07a73c17a 100644 (file)
@@ -54,6 +54,8 @@ static int c_cannot_inline_tree_fn PARAMS ((tree *));
 #define LANG_HOOKS_NAME "GNU C"
 #undef LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT c_init
+#undef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS c_init_options
 #undef LANG_HOOKS_DECODE_OPTION
index 14a02535f36f30c8524c8ed4e66598ff750b6591..6e797511e7d0ae8f0c10da147f0abfa0ec168e33 100644 (file)
@@ -50,7 +50,6 @@ end ifc
 #include "output.h"
 #include "toplev.h"
 #include "ggc.h"
-#include "diagnostic.h"  
   
 #ifdef MULTIBYTE_CHARS
 #include <locale.h>
@@ -3530,14 +3529,6 @@ init_reswords ()
     }
 }
 
-void
-finish_parse ()
-{
-  cpp_finish (parse_in);
-  /* Call to cpp_destroy () omitted for performance reasons.  */
-  errorcount += cpp_errors (parse_in);
-}
-
 #define NAME(type) cpp_type2name (type)
 
 static void
index a388f5115a02848eb8854a22d376438f6a4af2f1..06691eb681e1c7865116e8f408c0d0f4e43695c2 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-18  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * lex.c (cxx_finish): Call c_common_finish.
+       (finish_parse): Remove.
+
 2001-11-17  Kriang Lerdsuwanakij  <lerdsuwa@users.sourceforge.net>
 
        * decl.c (create_array_type_for_decl): Check if NAME is NULL_TREE
index 21e359402f8975d8ed46032b8112d749bdc5a117..c093fc1f0f7ec69ad366592f5b7d0927b4d59a49 100644 (file)
@@ -265,7 +265,8 @@ void
 cxx_finish ()
 {
   if (flag_gnu_xref)
-    GNU_xref_end (errorcount+sorrycount);
+    GNU_xref_end (errorcount + sorrycount);
+  c_common_finish ();
 }
 
 static int *
@@ -740,14 +741,6 @@ cxx_init (filename)
 
   return filename;
 }
-
-void
-finish_parse ()
-{
-  cpp_finish (parse_in);
-  /* Call to cpp_destroy () omitted for performance reasons.  */
-  errorcount += cpp_errors (parse_in);
-}
 \f
 inline void
 yyprint (file, yychar, yylval)
index 586b6e3f86cdf04d2f865572f324b2b1e248d4c4..38b3623e531c925d4805ab65fe40e761b0181807 100644 (file)
@@ -1,3 +1,8 @@
+Sun Nov 18 11:13:04 2001  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * com.c (finish_parse): Remove.
+       (ffe_finish): Move body of finish_parse.
+
 Thu Nov 15 10:06:38 2001  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * com.c (ffecom_init_decl_processing): Renamed from
index fb7bd4fd805c66976b4784af3fb10f6f98879974..2cf19d487378474e0b7ae188187f2b1877141db2 100644 (file)
@@ -14189,12 +14189,6 @@ ffecom_init_decl_processing ()
   ffe_init_0 ();
 }
 
-void
-finish_parse ()
-{
-  fclose (finput);
-}
-
 /* Delete the node BLOCK from the current binding level.
    This is used for the block inside a stmt expr ({...})
    so that the block can be reinserted where appropriate.  */
@@ -14303,6 +14297,8 @@ ffe_finish ()
 
   if (ffe_is_ffedebug ())
     malloc_pool_display (malloc_pool_image ());
+
+  fclose (finput);
 }
 
 static void
index 08264515f7fa5bbde7bd01898c86d729a9750970..d97977d5b7966ceab8da6982b4f7416a2bbfb410 100644 (file)
@@ -1,3 +1,8 @@
+2001-11-18  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * lang.c (finish_parse): Rename to java_finish.
+       (LANG_HOOKS_FINISH, java_finish): New.
+
 2001-11-15  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * decl.c (init_decl_processing): Rename java_init_decl_processing.
index 977ed175ec4010387c6c3e048e7bcf49d9d1c25e..979b261c30b10431bd61fa941920495af2742637 100644 (file)
@@ -49,6 +49,7 @@ struct string_option
 };
 
 static const char *java_init PARAMS ((const char *));
+static void java_finish PARAMS ((void));
 static void java_init_options PARAMS ((void));
 static int java_decode_option PARAMS ((int, char **));
 static void put_decl_string PARAMS ((const char *, int));
@@ -199,6 +200,8 @@ static int dependency_tracking = 0;
 #define LANG_HOOKS_NAME "GNU Java"
 #undef LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT java_init
+#undef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH java_finish
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS java_init_options
 #undef LANG_HOOKS_DECODE_OPTION
@@ -508,8 +511,8 @@ java_init (filename)
   return filename;
 }
 
-void
-finish_parse ()
+static void
+java_finish ()
 {
   jcf_dependency_write ();
 }
index 9823dc8797a89b60a6862fca65c757284b8c7529..0402940a398ac589d34a9a566d2a492a49fc9991 100644 (file)
@@ -61,7 +61,10 @@ struct lang_hooks
 
   /* 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).  */
+     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 last, as a finalizer.  */
index 3dd0a33a50e8610b7f3331e1a2c0d0cae4f72908..c98b61f02ab0a062cadcf85dd8cd9464486bd6de 100644 (file)
@@ -456,6 +456,8 @@ static int print_struct_values = 0;
 #define LANG_HOOKS_NAME "GNU Objective-C"
 #undef LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT objc_init
+#undef LANG_HOOKS_FINISH
+#define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS objc_init_options
 #undef LANG_HOOKS_DECODE_OPTION
index 786517b66c56a16ab6186f502bfe1aa86a69e07d..a3bdba671017202ed106345714439e981a8fed15 100644 (file)
@@ -165,8 +165,9 @@ 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 int lang_dependent_init PARAMS ((const char *));
 static void init_asm_output PARAMS ((const char *));
+static void finalize PARAMS ((void));
 
 static void set_target_switch PARAMS ((const char *));
 static const char *decl_name PARAMS ((tree, int));
@@ -2168,7 +2169,7 @@ compile_file ()
   timevar_pop (TV_PARSE);
 
   if (flag_syntax_only)
-    goto finish_syntax;
+    return;
 
   globals = getdecls ();
 
@@ -2250,19 +2251,6 @@ compile_file ()
             IDENT_ASM_OP, version_string);
 #endif
 
-  /* Language-specific end of compilation actions.  */
- finish_syntax:
-  (*lang_hooks.finish) ();
-
-  /* Close the dump files.  */
-
-  if (flag_gen_aux_info)
-    {
-      fclose (aux_info_file);
-      if (errorcount)
-       unlink (aux_info_file_name);
-    }
-
   if (optimize > 0 && open_dump_file (DFI_combine, NULL))
     {
       timevar_push (TV_DUMP);
@@ -2270,45 +2258,6 @@ compile_file ()
       close_dump_file (DFI_combine, NULL, NULL_RTX);
       timevar_pop (TV_DUMP);
     }
-
-  /* Close non-debugging input and output files.  Take special care to note
-     whether fclose returns an error, since the pages might still be on the
-     buffer chain while the file is open.  */
-
-  finish_parse ();
-
-  if (ferror (asm_out_file) != 0)
-    fatal_io_error ("error writing to %s", asm_file_name);
-  if (fclose (asm_out_file) != 0)
-    fatal_io_error ("error closing %s", asm_file_name);
-
-  /* Do whatever is necessary to finish printing the graphs.  */
-  if (graph_dump_format != no_graph)
-    {
-      int i;
-
-      for (i = 0; i < (int) DFI_MAX; ++i)
-       if (dump_file[i].initialized && dump_file[i].graph_dump_p)
-         {
-           char seq[16];
-           char *suffix;
-
-           sprintf (seq, ".%02d.", i);
-           suffix = concat (seq, dump_file[i].extension, NULL);
-           finish_graph_dump_file (dump_base_name, suffix);
-           free (suffix);
-         }
-    }
-
-  if (mem_report)
-    {
-      ggc_print_statistics ();
-      stringpool_statistics ();
-      dump_tree_statistics ();
-    }
-
-  /* Free up memory for the benefit of leak detectors.  */
-  free_reg_info ();
 }
 \f
 /* This is called from various places for FUNCTION_DECL, VAR_DECL,
@@ -5112,8 +5061,8 @@ lang_independent_init ()
   expand_dummy_function_end ();
 }
 \f
-/* Language-dependent initialization.  */
-static void
+/* Language-dependent initialization.  Returns non-zero on success.  */
+static int
 lang_dependent_init (name)
      const char *name;
 {
@@ -5125,10 +5074,11 @@ lang_dependent_init (name)
      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)
+    return 0;
 
-  if (name)
-    name = ggc_strdup (name);
-
+  /* Is this duplication necessary?  */
+  name = ggc_strdup (name);
   main_input_filename = input_filename = name;
   init_asm_output (name);
 
@@ -5154,6 +5104,65 @@ lang_dependent_init (name)
   (*debug_hooks->init) (name);
 
   timevar_pop (TV_SYMOUT);
+
+  return 1;
+}
+\f
+/* Clean up: close opened files, etc.  */
+
+static void
+finalize ()
+{
+  /* Close the dump files.  */
+  if (flag_gen_aux_info)
+    {
+      fclose (aux_info_file);
+      if (errorcount)
+       unlink (aux_info_file_name);
+    }
+
+  /* Close non-debugging input and output files.  Take special care to note
+     whether fclose returns an error, since the pages might still be on the
+     buffer chain while the file is open.  */
+
+  if (asm_out_file)
+    {
+      if (ferror (asm_out_file) != 0)
+       fatal_io_error ("error writing to %s", asm_file_name);
+      if (fclose (asm_out_file) != 0)
+       fatal_io_error ("error closing %s", asm_file_name);
+    }
+
+  /* Do whatever is necessary to finish printing the graphs.  */
+  if (graph_dump_format != no_graph)
+    {
+      int i;
+
+      for (i = 0; i < (int) DFI_MAX; ++i)
+       if (dump_file[i].initialized && dump_file[i].graph_dump_p)
+         {
+           char seq[16];
+           char *suffix;
+
+           sprintf (seq, ".%02d.", i);
+           suffix = concat (seq, dump_file[i].extension, NULL);
+           finish_graph_dump_file (dump_base_name, suffix);
+           free (suffix);
+         }
+    }
+
+  if (mem_report)
+    {
+      ggc_print_statistics ();
+      stringpool_statistics ();
+      dump_tree_statistics ();
+    }
+
+  /* Free up memory for the benefit of leak detectors.  */
+  free_reg_info ();
+
+  /* Language-specific end of compilation actions.  */
+  (*lang_hooks.finish) ();
 }
 \f
 /* Entry point of cc1, cc1plus, jc1, f771, etc.
@@ -5179,8 +5188,6 @@ toplev_main (argc, argv)
   if (exit_after_options)
     return (SUCCESS_EXIT_CODE);
 
-  /* Start timing total execution time.  */
-
   /* The bulk of command line switch processing.  */
   process_options ();
 
@@ -5193,10 +5200,11 @@ toplev_main (argc, argv)
      hashes etc.  */
   lang_independent_init ();
 
-  /* Language-dependent initialization.  */
-  lang_dependent_init (filename);
+  /* Language-dependent initialization.  Returns true on success.  */
+  if (lang_dependent_init (filename))
+    compile_file ();
 
-  compile_file ();
+  finalize ();
 
   /* Stop timing and print the times.  */
   timevar_stop (TV_TOTAL);
index 4fa60e7f5194a821baa0a36e52ec07b61e3b01e9..98ba6e59792173b52716d88b39c7cd3a2162bd77 100644 (file)
@@ -2647,8 +2647,6 @@ extern const char *(*decl_printable_name) PARAMS ((tree, int));
 
 extern void (*incomplete_decl_finalize_hook)   PARAMS ((tree));
 
-extern void finish_parse                       PARAMS ((void));
-
 /* Declare a predefined function.  Return the declaration.  This function is
    provided by each language frontend.  */
 extern tree builtin_function                   PARAMS ((const char *, tree, int,