langhooks.c (lang_hook_default_do_nothing, [...]): New defaults.
authorNeil Booth <neil@daikokuya.demon.co.uk>
Sun, 21 Oct 2001 21:03:48 +0000 (21:03 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sun, 21 Oct 2001 21:03:48 +0000 (21:03 +0000)
* 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
gcc/langhooks.c
gcc/langhooks.h
gcc/objc/objc-act.c
gcc/toplev.c
gcc/toplev.h

index 9e8abcc450563eae96dc8e04208cfe0bf40ad9b8..009967f384224868dcc7cc89388fe85341450269 100644 (file)
@@ -1,3 +1,12 @@
+2001-10-21  Neil Booth  <neil@daikokuya.demon.co.uk>
+
+       * 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  <ghazi@caip.rutgers.edu>
 
        * arm.h (FUNCTION_ARG_REGNO_P): Use IN_RANGE.
index ea0df90484831d0b0c3ea57eec159f33402c4b69..aa6422a325c3d09e766d41b10a9efcf1c6edb3af 100644 (file)
@@ -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 e3067fb261104db0c9e775ecabcc59cb5e228924..0b4d72f6c46e239daff88b35cdc8fd9f5bb9ed62 100644 (file)
@@ -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  <aoliva@redhat.com>
 
@@ -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, \
index 9da8ba08e7afcf9fef6e2f5d2f543e0c81350b58..8cf02865693309db1731a06e668715021bc4c2c7 100644 (file)
@@ -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
index 3bc9dac156ba3f628c42ce6243d706bb3d9f4efe..b702a8f7ecbd70257da8f3e4be44c492963e8537 100644 (file)
@@ -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);
index 61a277c376665c304d25d6421a9509daba5bf7d9..4203207f09657bb4ee15bd9c7f8ac0db8fb7bde1 100644 (file)
@@ -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.  */