This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Langhooks fix and cleanup
- To: gcc-patches at gcc dot gnu dot org
- Subject: Langhooks fix and cleanup
- From: Neil Booth <neil at daikokuya dot demon dot co dot uk>
- Date: Sat, 20 Oct 2001 00:07:32 +0100
This patch unconditionally defines the default langhooks; the
preprocessor conditions are superfluous clutter. It also gives them
defaults that are non-NULL, like Mark requests for target hooks.
I have then updated toplev.c to remove checks for NULL, and updated
comments in toplev.h.
Finally, I have brought objc into the new regime, which it has managed
to duck so far. Alexandre, I have a feeling that objc should be
sharing the inlining hooks of the C front end. If so, you know that
much better than I, so would you take care of that?
Bootstrapped x86 Linux, making check. OK to commit if successful?
Neil.
* 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.
* ojbc/objc-act.c: Include langhooks.h.
(lang_hooks): Initialize from macros.
Index: langhooks.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.c,v
retrieving revision 1.3
diff -u -p -r1.3 langhooks.c
--- langhooks.c 2001/10/11 06:50:50 1.3
+++ langhooks.c 2001/10/19 22:58:59
@@ -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
Index: langhooks.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/langhooks.h,v
retrieving revision 1.1
diff -u -p -r1.1 langhooks.h
--- langhooks.h 2001/10/08 20:54:07 1.1
+++ langhooks.h 2001/10/19 22:58:59
@@ -22,23 +22,14 @@ 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
+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
/* Declarations of default tree inlining hooks. */
tree tree_inlining_default_hook_walk_subtrees PARAMS ((tree*, int *,
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.521
diff -u -p -r1.521 toplev.c
--- toplev.c 2001/10/19 15:17:37 1.521
+++ toplev.c 2001/10/19 22:59:17
@@ -2221,8 +2221,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. */
@@ -2422,8 +2421,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. */
@@ -4669,8 +4667,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. */
@@ -4845,8 +4842,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);
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.74
diff -u -p -r1.74 toplev.h
--- toplev.h 2001/10/08 20:54:07 1.74
+++ toplev.h 2001/10/19 22:59:32
@@ -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. */
Index: objc/objc-act.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/objc/objc-act.c,v
retrieving revision 1.98
diff -u -p -r1.98 objc-act.c
--- objc-act.c 2001/10/12 16:01:16 1.98
+++ objc-act.c 2001/10/19 23:05:06
@@ -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
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