diff options
author | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-11-18 11:04:53 +0000 |
---|---|---|
committer | neil <neil@138bc75d-0d04-0410-961f-82ee72b054a4> | 2001-11-18 11:04:53 +0000 |
commit | cdc9fa3e38cf8c6354a9fb2769d7e282994d0b77 (patch) | |
tree | 2092e937365d4aa4305ac9206c9b38c72a6f6d56 /gcc/toplev.c | |
parent | 13d1072dd018d3eed6971a4da5408af398398dec (diff) | |
download | gcc-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
Diffstat (limited to 'gcc/toplev.c')
-rw-r--r-- | gcc/toplev.c | 136 |
1 files changed, 72 insertions, 64 deletions
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); |