summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-11-18 11:04:53 +0000
committerneil <neil@138bc75d-0d04-0410-961f-82ee72b054a4>2001-11-18 11:04:53 +0000
commitcdc9fa3e38cf8c6354a9fb2769d7e282994d0b77 (patch)
tree2092e937365d4aa4305ac9206c9b38c72a6f6d56
parent13d1072dd018d3eed6971a4da5408af398398dec (diff)
downloadgcc-cdc9fa3e38cf8c6354a9fb2769d7e282994d0b77.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@47141 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog19
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/misc.c14
-rw-r--r--gcc/c-common.c12
-rw-r--r--gcc/c-common.h1
-rw-r--r--gcc/c-lang.c2
-rw-r--r--gcc/c-parse.in9
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/lex.c11
-rw-r--r--gcc/f/ChangeLog5
-rw-r--r--gcc/f/com.c8
-rw-r--r--gcc/java/ChangeLog5
-rw-r--r--gcc/java/lang.c7
-rw-r--r--gcc/langhooks.h5
-rw-r--r--gcc/objc/objc-act.c2
-rw-r--r--gcc/toplev.c136
-rw-r--r--gcc/tree.h2
17 files changed, 149 insertions, 101 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 90b232c64a9..f7ff9539db8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index b5a7745b7da..0bd159ce95b 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -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.
diff --git a/gcc/ada/misc.c b/gcc/ada/misc.c
index 0ea1339be61..16e3e8ce24d 100644
--- a/gcc/ada/misc.c
+++ b/gcc/ada/misc.c
@@ -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. */
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 6b6b36b720f..dde1af3b892 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -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 ()
{
diff --git a/gcc/c-common.h b/gcc/c-common.h
index df6cd9d387f..7ccaef7ee8f 100644
--- a/gcc/c-common.h
+++ b/gcc/c-common.h
@@ -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));
diff --git a/gcc/c-lang.c b/gcc/c-lang.c
index 5655d8cfcdf..5a82c59ecdb 100644
--- a/gcc/c-lang.c
+++ b/gcc/c-lang.c
@@ -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
diff --git a/gcc/c-parse.in b/gcc/c-parse.in
index 14a02535f36..6e797511e7d 100644
--- a/gcc/c-parse.in
+++ b/gcc/c-parse.in
@@ -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
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a388f5115a0..06691eb681e 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c
index 21e359402f8..c093fc1f0f7 100644
--- a/gcc/cp/lex.c
+++ b/gcc/cp/lex.c
@@ -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);
-}
inline void
yyprint (file, yychar, yylval)
diff --git a/gcc/f/ChangeLog b/gcc/f/ChangeLog
index 586b6e3f86c..38b3623e531 100644
--- a/gcc/f/ChangeLog
+++ b/gcc/f/ChangeLog
@@ -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
diff --git a/gcc/f/com.c b/gcc/f/com.c
index fb7bd4fd805..2cf19d48737 100644
--- a/gcc/f/com.c
+++ b/gcc/f/com.c
@@ -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
diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog
index 08264515f7f..d97977d5b79 100644
--- a/gcc/java/ChangeLog
+++ b/gcc/java/ChangeLog
@@ -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.
diff --git a/gcc/java/lang.c b/gcc/java/lang.c
index 977ed175ec4..979b261c30b 100644
--- a/gcc/java/lang.c
+++ b/gcc/java/lang.c
@@ -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 ();
}
diff --git a/gcc/langhooks.h b/gcc/langhooks.h
index 9823dc8797a..0402940a398 100644
--- a/gcc/langhooks.h
+++ b/gcc/langhooks.h
@@ -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. */
diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c
index 3dd0a33a50e..c98b61f02ab 100644
--- a/gcc/objc/objc-act.c
+++ b/gcc/objc/objc-act.c
@@ -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
diff --git a/gcc/toplev.c b/gcc/toplev.c
index 786517b66c5..a3bdba67101 100644
--- a/gcc/toplev.c
+++ b/gcc/toplev.c
@@ -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 ();
}
/* This is called from various places for FUNCTION_DECL, VAR_DECL,
@@ -5112,8 +5061,8 @@ lang_independent_init ()
expand_dummy_function_end ();
}
-/* 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;
+}
+
+/* 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) ();
}
/* 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);
diff --git a/gcc/tree.h b/gcc/tree.h
index 4fa60e7f519..98ba6e59792 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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,