From 77b1a9217b8359f417c7e090e857c464d2e8778a Mon Sep 17 00:00:00 2001 From: Neil Booth Date: Sun, 21 Oct 2001 21:03:48 +0000 Subject: [PATCH] langhooks.c (lang_hook_default_do_nothing, [...]): New defaults. * langhooks.c (lang_hook_default_do_nothing, lang_hook_default_decode_option): New defaults. * langhooks.h: Make hooks unconditional and non-NULL. * toplev.c (compile_file, toplev_main): Update. * toplev.h: Update comments. * objc/objc-act.c (lang_hooks): Update to new paradigm. From-SVN: r46396 --- gcc/ChangeLog | 9 +++++++ gcc/langhooks.c | 14 +++++++++++ gcc/langhooks.h | 57 ++++++++++++++++----------------------------- gcc/objc/objc-act.c | 16 +++++++++---- gcc/toplev.c | 12 ++++------ gcc/toplev.h | 6 ++--- 6 files changed, 60 insertions(+), 54 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9e8abcc4505..009967f3842 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2001-10-21 Neil Booth + + * langhooks.c (lang_hook_default_do_nothing, + lang_hook_default_decode_option): New defaults. + * langhooks.h: Make hooks unconditional and non-NULL. + * toplev.c (compile_file, toplev_main): Update. + * toplev.h: Update comments. + * objc/objc-act.c (lang_hooks): Update to new paradigm. + 2001-10-21 Kaveh R. Ghazi * arm.h (FUNCTION_ARG_REGNO_P): Use IN_RANGE. diff --git a/gcc/langhooks.c b/gcc/langhooks.c index ea0df904848..aa6422a325c 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -29,6 +29,20 @@ Boston, MA 02111-1307, USA. */ #include "integrate.h" #include "langhooks.h" +/* Do nothing; in many cases the default hook. */ +void +lang_hook_default_do_nothing () +{ +} + +/* Do nothing; the default hook to decode an option. */ +int +lang_hook_default_decode_option (argc, argv) + int argc ATTRIBUTE_UNUSED; + char **argv ATTRIBUTE_UNUSED; +{ + return 0; +} /* lang_hooks.tree_inlining.walk_subtrees is called by walk_tree() after handling common cases, but before walking code-specific diff --git a/gcc/langhooks.h b/gcc/langhooks.h index e3067fb2611..0b4d72f6c46 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -1,4 +1,4 @@ -/* Macros to initialize the lang_hooks data structure. +/* Default macros to initialize the lang_hooks data structure. Copyright 2001 Free Software Foundation, Inc. Contributed by Alexandre Oliva @@ -22,26 +22,25 @@ Boston, MA 02111-1307, USA. */ #ifndef GCC_LANG_HOOKS_H #define GCC_LANG_HOOKS_H -/* Older hooks, that don't go in sub-structures for backward - compatibility. */ -#ifndef LANG_HOOKS_INIT -#define LANG_HOOKS_INIT NULL -#endif -#ifndef LANG_HOOKS_FINISH -#define LANG_HOOKS_FINISH NULL -#endif -#ifndef LANG_HOOKS_INIT_OPTIONS -#define LANG_HOOKS_INIT_OPTIONS NULL -#endif -#ifndef LANG_HOOKS_DECODE_OPTION -#define LANG_HOOKS_DECODE_OPTION NULL -#endif -#ifndef LANG_HOOKS_POST_OPTIONS -#define LANG_HOOKS_POST_OPTIONS NULL -#endif -#ifndef LANG_HOOKS_HONOR_READONLY -#define LANG_HOOKS_HONOR_READONLY 0 -#endif +/* Note to creators of new hooks: + + The macros in this file should NOT be surrounded by a + #ifdef...#endif pair, since this file declares the defaults. Each + front end overrides any hooks it wishes to, in the file containing + its struct lang_hooks, AFTER including this file. */ + +/* See toplev.h for the definition and documentation of each hook. */ + +extern void lang_hook_default_do_nothing PARAMS ((void)); +extern int lang_hook_default_decode_option PARAMS ((int, char **)); + +#define LANG_HOOKS_INIT lang_hook_default_do_nothing +#define LANG_HOOKS_FINISH lang_hook_default_do_nothing +#define LANG_HOOKS_INIT_OPTIONS lang_hook_default_do_nothing +#define LANG_HOOKS_DECODE_OPTION lang_hook_default_decode_option +#define LANG_HOOKS_POST_OPTIONS lang_hook_default_do_nothing + +#define LANG_HOOKS_HONOR_READONLY false /* Declarations of default tree inlining hooks. */ tree tree_inlining_default_hook_walk_subtrees PARAMS ((tree*, int *, @@ -60,38 +59,22 @@ tree tree_inlining_default_hook_copy_res_decl_for_inlining PARAMS ((tree, tree, int tree_inlining_default_hook_anon_aggr_type_p PARAMS ((tree)); /* Tree inlining hooks. */ -#ifndef LANG_HOOKS_TREE_INLINING_WALK_SUBTREES #define LANG_HOOKS_TREE_INLINING_WALK_SUBTREES \ tree_inlining_default_hook_walk_subtrees -#endif -#ifndef LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN #define LANG_HOOKS_TREE_INLINING_CANNOT_INLINE_TREE_FN \ tree_inlining_default_hook_cannot_inline_tree_fn -#endif -#ifndef LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS #define LANG_HOOKS_TREE_INLINING_DISREGARD_INLINE_LIMITS \ tree_inlining_default_hook_disregard_inline_limits -#endif -#ifndef LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS #define LANG_HOOKS_TREE_INLINING_ADD_PENDING_FN_DECLS \ tree_inlining_default_hook_add_pending_fn_decls -#endif -#ifndef LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P #define LANG_HOOKS_TREE_INLINING_TREE_CHAIN_MATTERS_P \ tree_inlining_default_hook_tree_chain_matters_p -#endif -#ifndef LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P #define LANG_HOOKS_TREE_INLINING_AUTO_VAR_IN_FN_P \ tree_inlining_default_hook_auto_var_in_fn_p -#endif -#ifndef LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING #define LANG_HOOKS_TREE_INLINING_COPY_RES_DECL_FOR_INLINING \ tree_inlining_default_hook_copy_res_decl_for_inlining -#endif -#ifndef LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P #define LANG_HOOKS_TREE_INLINING_ANON_AGGR_TYPE_P \ tree_inlining_default_hook_anon_aggr_type_p -#endif #define LANG_HOOKS_TREE_INLINING_INITIALIZER { \ LANG_HOOKS_TREE_INLINING_WALK_SUBTREES, \ diff --git a/gcc/objc/objc-act.c b/gcc/objc/objc-act.c index 9da8ba08e7a..8cf02865693 100644 --- a/gcc/objc/objc-act.c +++ b/gcc/objc/objc-act.c @@ -58,6 +58,7 @@ Boston, MA 02111-1307, USA. */ #include "cpplib.h" #include "debug.h" #include "target.h" +#include "langhooks.h" /* This is the default way of generating a method name. */ /* I am not sure it is really correct. @@ -449,12 +450,17 @@ static int generating_instance_variables = 0; static int print_struct_values = 0; +#undef LANG_HOOKS_INIT +#define LANG_HOOKS_INIT objc_init +#undef LANG_HOOKS_INIT_OPTIONS +#define LANG_HOOKS_INIT_OPTIONS objc_init_options +#undef LANG_HOOKS_DECODE_OPTION +#define LANG_HOOKS_DECODE_OPTION objc_decode_option +#undef LANG_HOOKS_POST_OPTIONS +#define LANG_HOOKS_POST_OPTIONS objc_post_options + /* Each front end provides its own. */ -struct lang_hooks lang_hooks = {objc_init, - NULL, /* objc_finish */ - objc_init_options, - objc_decode_option, - objc_post_options}; +struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER; /* Post-switch processing. */ static void diff --git a/gcc/toplev.c b/gcc/toplev.c index 3bc9dac156b..b702a8f7ecb 100644 --- a/gcc/toplev.c +++ b/gcc/toplev.c @@ -2227,8 +2227,7 @@ compile_file (name) /* Perform language-specific initialization. This may set main_input_filename. */ - if (lang_hooks.init) - (*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. */ @@ -2428,8 +2427,7 @@ compile_file (name) /* Language-specific end of compilation actions. */ finish_syntax: - if (lang_hooks.finish) - (*lang_hooks.finish) (); + (*lang_hooks.finish) (); /* Close the dump files. */ @@ -4671,8 +4669,7 @@ toplev_main (argc, argv) add_params (lang_independent_params, LAST_PARAM); /* Perform language-specific options intialization. */ - if (lang_hooks.init_options) - (*lang_hooks.init_options) (); + (*lang_hooks.init_options) (); /* Scan to see what optimization level has been specified. That will determine the default value of many flags. */ @@ -4847,8 +4844,7 @@ toplev_main (argc, argv) } /* All command line options have been processed. */ - if (lang_hooks.post_options) - (*lang_hooks.post_options) (); + (*lang_hooks.post_options) (); if (exit_after_options) exit (0); diff --git a/gcc/toplev.h b/gcc/toplev.h index 61a277c3766..4203207f096 100644 --- a/gcc/toplev.h +++ b/gcc/toplev.h @@ -138,7 +138,7 @@ struct lang_hooks_for_tree_inlining int (*anon_aggr_type_p) PARAMS ((union tree_node *)); }; -/* Language-specific hooks. Can be NULL unless otherwise specified. */ +/* Language-specific hooks. See langhooks.h for defaults. */ struct lang_hooks { @@ -158,9 +158,7 @@ struct lang_hooks option. If this function returns a negative number, then its absolute value is the number of command-line arguments used, but, in addition, no language-independent option processing should be - done for this option. - - This hook cannot be NULL. */ + done for this option. */ int (*decode_option) PARAMS ((int, char **)); /* Called when all command line options have been processed. */