diff --git a/gcc/c-lang.c b/gcc/c-lang.c index 5b08679c5e1..f8cefb36490 100644 --- a/gcc/c-lang.c +++ b/gcc/c-lang.c @@ -38,10 +38,13 @@ Boston, MA 02111-1307, USA. */ static int c_tree_printer PARAMS ((output_buffer *)); static int c_missing_noreturn_ok_p PARAMS ((tree)); +static void c_init PARAMS ((void)); static void c_post_options PARAMS ((void)); /* Each front end provides its own. */ -struct lang_hooks lang_hooks = {c_post_options}; +struct lang_hooks lang_hooks = {c_init, + NULL, /* c_finish */ + c_post_options}; /* Post-switch processing. */ static void @@ -69,8 +72,8 @@ lang_init_options () flag_bounds_check = -1; } -void -lang_init () +static void +c_init () { c_common_lang_init (); @@ -95,11 +98,6 @@ lang_init () c_parse_init (); } -void -lang_finish () -{ -} - const char * lang_identify () { diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index e69a23acb27..e2309e910f5 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -4062,8 +4062,6 @@ extern tree make_pointer_declarator PARAMS ((tree, tree)); extern tree make_reference_declarator PARAMS ((tree, tree)); extern tree make_call_declarator PARAMS ((tree, tree, tree, tree)); extern void set_quals_and_spec PARAMS ((tree, tree, tree)); -extern void lang_init PARAMS ((void)); -extern void lang_finish PARAMS ((void)); extern void print_parse_statistics PARAMS ((void)); extern void do_pending_inlines PARAMS ((void)); extern void process_next_inline PARAMS ((struct unparsed_text *)); diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index e07a7498e98..8bdd43e39f4 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -59,7 +59,6 @@ typedef struct priority_info_s { int destructions_p; } *priority_info; -static void cxx_post_options PARAMS ((void)); static void mark_vtable_entries PARAMS ((tree)); static void grok_function_init PARAMS ((tree, tree)); static int finish_vtable_vardecl PARAMS ((tree *, void *)); @@ -544,16 +543,6 @@ static const char * const unsupported_options[] = { "strict-prototype", }; -/* Each front end provides its own. */ -struct lang_hooks lang_hooks = {cxx_post_options}; - -/* Post-switch processing. */ -static void -cxx_post_options () -{ - cpp_post_options (parse_in); -} - /* Compare two option strings, pointed two by P1 and P2, for use with bsearch. */ diff --git a/gcc/cp/lex.c b/gcc/cp/lex.c index a203ac963df..3203b4cec2c 100644 --- a/gcc/cp/lex.c +++ b/gcc/cp/lex.c @@ -61,6 +61,9 @@ static void handle_pragma_vtable PARAMS ((cpp_reader *)); static void handle_pragma_unit PARAMS ((cpp_reader *)); static void handle_pragma_interface PARAMS ((cpp_reader *)); static void handle_pragma_implementation PARAMS ((cpp_reader *)); +static void cxx_init PARAMS ((void)); +static void cxx_finish PARAMS ((void)); +static void cxx_post_options PARAMS ((void)); #ifdef GATHER_STATISTICS #ifdef REDUCE_LENGTH @@ -240,7 +243,17 @@ static const char *cplus_tree_code_name[] = { }; #undef DEFTREECODE -/* toplev.c needs to call these. */ +/* Each front end provides its own hooks, for toplev.c. */ +struct lang_hooks lang_hooks = {cxx_init, + cxx_finish, + cxx_post_options}; + +/* Post-switch processing. */ +static void +cxx_post_options () +{ + cpp_post_options (parse_in); +} void lang_init_options () @@ -259,8 +272,8 @@ lang_init_options () set_message_prefixing_rule (DIAGNOSTICS_SHOW_PREFIX_ONCE); } -void -lang_init () +static void +cxx_init () { c_common_lang_init (); @@ -268,8 +281,8 @@ lang_init () init_repo (input_filename); } -void -lang_finish () +static void +cxx_finish () { if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount); } diff --git a/gcc/f/com.c b/gcc/f/com.c index f6f80e03bac..cdd48bf6049 100644 --- a/gcc/f/com.c +++ b/gcc/f/com.c @@ -14677,7 +14677,12 @@ insert_block (block) } /* Each front end provides its own. */ -struct lang_hooks lang_hooks = {NULL /* post_options */}; +static void f_init PARAMS ((void)); +static void f_finish PARAMS ((void)); + +struct lang_hooks lang_hooks = {f_init, + f_finish, + NULL /* post_options */}; int lang_decode_option (argc, argv) @@ -14697,8 +14702,8 @@ lang_print_xnode (file, node, indent) { } -void -lang_finish () +static void +f_finish () { ffe_terminate_0 (); @@ -14738,8 +14743,8 @@ lang_init_options () flag_complex_divide_method = 1; } -void -lang_init () +static void +f_init () { /* If the file is output from cpp, it should contain a first line `# 1 "real-filename"', and the current design of gcc (toplev.c diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 3a9f34509dd..9b299b25047 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -45,6 +45,7 @@ struct string_option int on_value; }; +static void java_init PARAMS ((void)); static void put_decl_string PARAMS ((const char *, int)); static void put_decl_node PARAMS ((tree)); static void java_dummy_print PARAMS ((const char *)); @@ -187,7 +188,9 @@ static int dependency_tracking = 0; #define DEPEND_FILE_ALREADY_SET 8 /* Each front end provides its own. */ -struct lang_hooks lang_hooks = {NULL /* post_options */}; +struct lang_hooks lang_hooks = {java_init, + NULL, /* java_finish */ + NULL /* post_options */}; /* Process an option that can accept a `no-' form. Return 1 if option found, 0 otherwise. */ @@ -615,8 +618,8 @@ lang_print_error (file) } -void -lang_init () +static void +java_init () { #if 0 extern int flag_minimal_debug; @@ -682,11 +685,6 @@ lang_init_options () flag_bounds_check = 1; } -void -lang_finish () -{ -} - const char * lang_identify () { diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index e2daab1651c..b70c3e6dfd3 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -149,6 +149,7 @@ char *util_firstobj; static void init_objc PARAMS ((void)); static void finish_objc PARAMS ((void)); static void objc_post_options PARAMS ((void)); +static void objc_init PARAMS ((void)); /* Code generation. */ @@ -628,7 +629,9 @@ static int generating_instance_variables = 0; static int print_struct_values = 0; /* Each front end provides its own. */ -struct lang_hooks lang_hooks = {objc_post_options}; +struct lang_hooks lang_hooks = {objc_init, + NULL, /* objc_finish */ + objc_post_options}; /* Post-switch processing. */ static void @@ -707,8 +710,8 @@ lang_init_options () c_language = clk_objective_c; } -void -lang_init () +static void +objc_init () { /* Force the line number back to 0; check_newline will have raised it to 1, which will make the builtin functions appear @@ -765,11 +768,6 @@ finish_file () fclose (gen_declaration_file); } -void -lang_finish () -{ -} - const char * lang_identify () { diff --git a/gcc/toplev.c b/gcc/toplev.c index 0d51302471f..32effd4332b 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2248,7 +2248,8 @@ compile_file (name) /* Perform language-specific initialization. This may set main_input_filename. */ - lang_init (); + if (lang_hooks.init) + (*lang_hooks.init) (); /* If the input doesn't start with a #line, use the input name as the official input file name. */ @@ -2480,7 +2481,8 @@ compile_file (name) /* Language-specific end of compilation actions. */ finish_syntax: - lang_finish (); + if (lang_hooks.finish) + (*lang_hooks.finish) (); /* Close the dump files. */ diff --git a/gcc/toplev.h b/gcc/toplev.h index 05fca0103a1..f0c37f8c753 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -133,10 +133,16 @@ extern int sorrycount; extern const char *progname; -/* Language-specific hooks. */ +/* Language-specific hooks. Can be NULL unless otherwise specified. */ struct lang_hooks { - /* If non-NULL, called when all command line options have been processed. */ + /* Called first, to initialize the front end. */ + void (*init) PARAMS ((void)); + + /* Called last, as a finalizer. */ + void (*finish) PARAMS ((void)); + + /* Called when all command line options have been processed. */ void (*post_options) PARAMS ((void)); }; diff --git a/gcc/tree.h b/gcc/tree.h index 33e921207e1..b6129fc8f4b 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2571,11 +2571,6 @@ extern void init_lex PARAMS ((void)); /* Function of no arguments for initializing the symbol table. */ extern void init_decl_processing PARAMS ((void)); -/* Functions called with no arguments at the beginning and end or processing - the input source file. */ -extern void lang_init PARAMS ((void)); -extern void lang_finish PARAMS ((void)); - /* Function to identify which front-end produced the output file. */ extern const char *lang_identify PARAMS ((void));