hooks.c (hook_int_size_t_constcharptr_int_0): New.
authorNeil Booth <neil@daikokuya.co.uk>
Wed, 11 Jun 2003 22:21:10 +0000 (22:21 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Wed, 11 Jun 2003 22:21:10 +0000 (22:21 +0000)
* hooks.c (hook_int_size_t_constcharptr_int_0): New.
* hooks.h (hook_int_size_t_constcharptr_int_0): New.
* langhooks-def.h (lhd_decode_option, LANG_HOOKS_DECODE_OPTION): Die.
(LANG_HOOKS_HANDLE_OPTION, LANG_HOOKS_INITIALIZER): Update.
* langhooks.c (lhd_decode_option): Remove.
* langhooks.h (struct lang_hooks): Remove decode_option.
* opts.c (handle_option): No longer use decode_option.
java:
* Make-lang.in: Handle mostlyclean.
treelang:
* Make-lang.in: Update for option handling.
* lang.opt: New.
* tree1.c: Include opts.h and t-options.h.
(treelang_decode_option): Remove.
(treelang_handle_option): New.
* treetree.c (LANG_HOOKS_DECODE_OPTION): Remove.
(LANG_HOOKS_HANDLE_OPTION): Override.
* treetree.h (treelang_decode_option): Remove.
(treelang_handle_option): New.

From-SVN: r67799

15 files changed:
gcc/ChangeLog
gcc/hooks.c
gcc/hooks.h
gcc/java/ChangeLog
gcc/java/Make-lang.in
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/opts.c
gcc/treelang/ChangeLog
gcc/treelang/Make-lang.in
gcc/treelang/lang.opt [new file with mode: 0644]
gcc/treelang/tree1.c
gcc/treelang/treetree.c
gcc/treelang/treetree.h

index 018bb83a3f5ce735dac4ce79e71eca146a204aec..cf8050db53d2714d4b0ff793bec25b861d330a9c 100644 (file)
@@ -1,3 +1,13 @@
+2003-06-11  Neil Booth  <neil@daikokuya.co.uk>
+
+       * hooks.c (hook_int_size_t_constcharptr_int_0): New.
+       * hooks.h (hook_int_size_t_constcharptr_int_0): New.
+       * langhooks-def.h (lhd_decode_option, LANG_HOOKS_DECODE_OPTION): Die.
+       (LANG_HOOKS_HANDLE_OPTION, LANG_HOOKS_INITIALIZER): Update.
+       * langhooks.c (lhd_decode_option): Remove.
+       * langhooks.h (struct lang_hooks): Remove decode_option.
+       * opts.c (handle_option): No longer use decode_option.
+
 2003-06-11  Zdenek Dvorak  <rakdver@atrey.karlin.mff.cuni.cz>
 
        * cfgloopanal.c (variable_initial_value): Update the set of altered
index a80ded7fc41df23b970a4275919414f27a8d0c12..438af66f921c89b5f1122cbe2b5c12caa36617d3 100644 (file)
@@ -110,6 +110,14 @@ hook_int_void_0 (void)
   return 0;
 }
 
+int
+hook_int_size_t_constcharptr_int_0 (size_t a ATTRIBUTE_UNUSED,
+                                   const char *b ATTRIBUTE_UNUSED,
+                                   int c ATTRIBUTE_UNUSED)
+{
+  return 0;
+}
+
 void
 hook_void_tree (a)
      tree a ATTRIBUTE_UNUSED;
index 407440fe33188b18f82b71247c7fade131d2fac8..15b742da178304fb81b766a1034c7853f4162b80 100644 (file)
@@ -40,6 +40,7 @@ void hook_void_tree_treeptr PARAMS ((tree, tree *));
 int hook_int_tree_tree_1 PARAMS ((tree, tree));
 int hook_int_rtx_0 PARAMS ((rtx));
 int hook_int_void_0 (void);
+int hook_int_size_t_constcharptr_int_0 (size_t, const char *, int);
 
 bool default_can_output_mi_thunk_no_vcall
   PARAMS ((tree, HOST_WIDE_INT, HOST_WIDE_INT, tree));
index 9d4f9b5e5dc793430c8afefaacfaa56a21eec212..fcd451d536246b245a0a42215bffce1cb46e1d7e 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-11  Neil Booth  <neil@daikokuya.co.uk>
+
+       * Make-lang.in: Handle mostlyclean.
+
 2003-06-11  Tom Tromey  <tromey@redhat.com>
 
        * lang.c (java_handle_option): Update dependency_tracking for
index a4356d7f79b71a7dbfe04fd79f995f1233a38872..7bac1872649134626e6664b8b94168154852560d 100644 (file)
@@ -237,6 +237,7 @@ java.install-info: installdirs
 java.mostlyclean:
        -rm -f java/*$(objext) $(DEMANGLER_PROG)
        -rm -f java/*$(coverageexts)
+       -rm -f java/j-options.c java/j-options.h
        -rm -f jc1$(exeext) $(GCJ)$(exeext) jvgenmain$(exeext) gcjh$(exeext) jv-scan$(exeext) jcf-dump$(exeext) s-java
 java.clean:
 java.distclean:
index 8e6f8424c8afd19904c58629522d0b6a811e919d..a7f0abcd39f8fc1b87115a242e8f5098f9ccb02d 100644 (file)
@@ -35,9 +35,7 @@ extern HOST_WIDE_INT hook_get_alias_set_0     PARAMS ((tree));
    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.
-
-   Prefix all default hooks with "lhd_".  */
+   its struct lang_hooks, AFTER including this file.  */
 
 /* See langhooks.h for the definition and documentation of each hook.  */
 
@@ -45,7 +43,6 @@ extern void lhd_do_nothing PARAMS ((void));
 extern void lhd_do_nothing_t PARAMS ((tree));
 extern void lhd_do_nothing_i PARAMS ((int));
 extern void lhd_do_nothing_f PARAMS ((struct function *));
-extern int lhd_decode_option PARAMS ((int, char **));
 extern bool lhd_post_options PARAMS ((const char **));
 extern HOST_WIDE_INT lhd_get_alias_set PARAMS ((tree));
 extern tree lhd_return_tree PARAMS ((tree));
@@ -94,8 +91,7 @@ void write_global_declarations PARAMS ((void));
 #define LANG_HOOKS_PARSE_FILE          lhd_do_nothing_i
 #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack
 #define LANG_HOOKS_INIT_OPTIONS                hook_int_void_0
-#define LANG_HOOKS_DECODE_OPTION       lhd_decode_option
-#define LANG_HOOKS_HANDLE_OPTION       NULL
+#define LANG_HOOKS_HANDLE_OPTION       hook_int_size_t_constharptr_int_0
 #define LANG_HOOKS_POST_OPTIONS                lhd_post_options
 #define LANG_HOOKS_GET_ALIAS_SET       lhd_get_alias_set
 #define LANG_HOOKS_EXPAND_CONSTANT     lhd_return_tree
@@ -246,7 +242,6 @@ int lhd_tree_dump_type_quals                        PARAMS ((tree));
   LANG_HOOKS_IDENTIFIER_SIZE, \
   LANG_HOOKS_TREE_SIZE, \
   LANG_HOOKS_INIT_OPTIONS, \
-  LANG_HOOKS_DECODE_OPTION, \
   LANG_HOOKS_HANDLE_OPTION, \
   LANG_HOOKS_POST_OPTIONS, \
   LANG_HOOKS_INIT, \
index 2bc91481eee5fa764769b628959947014abda780..423bb5f421b2c29b43fbff7bf379526ed2986f9e 100644 (file)
@@ -83,16 +83,6 @@ lhd_return_null_tree (t)
   return NULL_TREE;
 }
 
-/* Do nothing; the default hook to decode an option.  */
-
-int
-lhd_decode_option (argc, argv)
-     int argc ATTRIBUTE_UNUSED;
-     char **argv ATTRIBUTE_UNUSED;
-{
-  return 0;
-}
-
 /* The default post options hook.  */
 
 bool
index fb648bf51ae79d767c1d38fe93c2200df36f790a..cfb26de599497e250d45f0f87c664e0c9dd443de 100644 (file)
@@ -206,16 +206,6 @@ struct lang_hooks
      the language mask to filter the switch array with.  */
   int (*init_options) PARAMS ((void));
 
-  /* Function called with an option vector as argument, to decode a
-     single option (typically starting with -f or -W or +).  It should
-     return the number of command-line arguments it uses if it handles
-     the option, or 0 and not complain if it does not recognize the
-     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.  Obsoleted by handle_option.  */
-  int (*decode_option) PARAMS ((int, char **));
-
   /* Handle the switch CODE, which has real type enum opt_code from
      options.h.  If the switch takes an argument, it is passed in ARG
      which points to permanent storage.  The handler is resonsible for
index 0911d388ff81243b1af2aa2e781c7945d5122622..25dacf2131d27f6abf7ac01430ba9bf358418f3b 100644 (file)
@@ -118,7 +118,7 @@ find_opt (const char *input, int lang_mask)
 
 /* Handle the switch beginning at ARGV, with ARGC remaining.  */
 int
-handle_option (int argc, char **argv, int lang_mask)
+handle_option (int argc ATTRIBUTE_UNUSED, char **argv, int lang_mask)
 {
   size_t opt_index;
   const char *opt, *arg = 0;
@@ -127,10 +127,6 @@ handle_option (int argc, char **argv, int lang_mask)
   int result = 0, temp;
   const struct cl_option *option;
 
-  /* If the front end isn't yet converted, use the old hook.  */
-  if (!lang_hooks.handle_option)
-    return (*lang_hooks.decode_option) (argc, argv);
-
   opt = argv[0];
 
   /* Interpret "-" or a non-switch as a file name.  */
index 668b6d29d79790d725d05dadf5d4ada1314bde04..c5c063bff6c513057412a94a57e842f4545bd444 100644 (file)
@@ -1,3 +1,15 @@
+2003-06-11  Neil Booth  <neil@daikokuya.co.uk>
+
+       * Make-lang.in: Update for option handling.
+       * lang.opt: New.
+       * tree1.c: Include opts.h and t-options.h.
+       (treelang_decode_option): Remove.
+       (treelang_handle_option): New.
+       * treetree.c (LANG_HOOKS_DECODE_OPTION): Remove.
+       (LANG_HOOKS_HANDLE_OPTION): Override.
+       * treetree.h (treelang_decode_option): Remove.
+       (treelang_handle_option): New.
+
 2003-06-08  Andreas Jaeger  <aj@suse.de>
 
        * Make-lang.in: Update.
index ca3bd3098e68ff255250f63a705244dc90afd9d7..d5e96af4bcd4e10cbe8bf5a6704f938cdc87a752 100644 (file)
@@ -85,11 +85,11 @@ treelang.done: tree1$(exeext)
 # core compiler
 tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/parse.o\
        $(TREE_BE_LIBS) c-convert.o c-typeck.o c-common.o c-cppbuiltin.o \
-       c-decl.o attribs.o
+       c-decl.o attribs.o treelang/t-options.o
        $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
        treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/parse.o \
        c-convert.o c-typeck.o c-common.o c-cppbuiltin.o c-decl.o attribs.o \
-       $(TREE_BE_LIBS)
+       $(TREE_BE_LIBS) treelang/t-options.o
 
 #\f
 # Compiling object files from source files.
@@ -98,7 +98,7 @@ tree1$(exeext): treelang/tree1.o treelang/treetree.o treelang/lex.o treelang/par
 
 treelang/tree1.o: treelang/tree1.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
   flags.h toplev.h $(GGC_H) $(TREE_H) diagnostic.h treelang/treelang.h \
-  input.h treelang/treetree.h \
+  input.h treelang/treetree.h treelang/t-options.h \
   treelang/treetree.h gt-treelang-tree1.h gtype-treelang.h
 
 treelang/treetree.o: treelang/treetree.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
@@ -112,6 +112,12 @@ treelang/parse.o: treelang/parse.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
 treelang/lex.o: treelang/lex.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
   $(TM_H) diagnostic.h $(TREE_H) treelang/treelang.h input.h treelang/parse.h
 
+treelang/t-options.c: treelang/lang.opt opts.sh treelang/t-options.h
+
+treelang/t-options.h: treelang/lang.opt opts.sh
+       AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh treelang/t-options.c \
+               treelang/t-options.h $(srcdir)/treelang/lang.opt
+
 # generated files the files from lex and yacc are put into the source
 # directory in case someone wants to build but does not have
 # lex/yacc
@@ -122,6 +128,7 @@ $(srcdir)/treelang/lex.c: $(srcdir)/treelang/lex.l
 $(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.h: $(srcdir)/treelang/parse.y
        $(BISON) $(BISONFLAGS) -v --defines \
        --output=$(srcdir)/treelang/parse.c $(srcdir)/treelang/parse.y
+
 # -v
 
 gt-treelang-tree1.h gtype-treelang.h : s-gtype; @true
@@ -230,6 +237,7 @@ treelang.mostlyclean:
            rm -f treelang/$$name$(exeext); \
          fi ; \
        done
+       -rm -f treelang/t-options.c treelang/t-options.h
        -rm -f treelang/*$(objext)
        -rm -f treelang/*$(coverageexts)
        -rm treelang.done
diff --git a/gcc/treelang/lang.opt b/gcc/treelang/lang.opt
new file mode 100644 (file)
index 0000000..5d3a266
--- /dev/null
@@ -0,0 +1,59 @@
+; Options for the treelang front end.
+; Copyright (C) 2003 Free Software Foundation, Inc.
+;
+; This file is part of GCC.
+;
+; GCC is free software; you can redistribute it and/or modify it under
+; the terms of the GNU General Public License as published by the Free
+; Software Foundation; either version 2, or (at your option) any later
+; version.
+; 
+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+; WARRANTY; without even the implied warranty of MERCHANTABILITY or
+; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+; for more details.
+; 
+; You should have received a copy of the GNU General Public License
+; along with GCC; see the file COPYING.  If not, write to the Free
+; Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+; 02111-1307, USA.
+
+
+; This file is processed by the script opts.sh.  It is a database of
+; command line options, with each record separated by a blank line,
+; and each field appearing on its own line.  The first field is the
+; command-line switch with the leading "-" removed.  All options
+; beginning with "f" or "W" are implicitly assumed to take a "no-"
+; form; this form should not be listed.  If you do not want this
+; negative form and you want it to be automatically rejected, add
+; RejectNegative to the second field.
+
+; The second field should contain "Tree".  If the switch takes an
+; argument, then you should also specify "Joined" and/or "Separate" to
+; indicate where the argument can appear.
+
+; Comments can appear on their own line anwhere in the file, preceded
+; by a semicolon.  Whitespace is permitted before the semicolon.
+
+; For each switch XXX below, an enumeration constant is created by the
+; script opts.sh spelt OPT_XXX, but with all non-alphanumeric
+; characters replaced with an underscore.
+
+; Please try to keep this file in ASCII collating order.
+
+-help
+Tree
+
+flexer-trace
+Tree
+
+fparser-trace
+Tree
+
+v
+Tree
+
+y
+Tree
+
+; This comment is to ensure we retain the blank line above.
index 3a6681a9b0f6f20d39ea65e886c80e7d2692dae4..f4e5fa84cb582dd5d1e3e3a17fcb3092d35f1669 100644 (file)
@@ -44,6 +44,8 @@
 
 #include "treelang.h"
 #include "treetree.h"
+#include "opts.h"
+#include "t-options.h"
 
 extern int yyparse (void);
 
@@ -86,98 +88,54 @@ static int version_done = 0;
 
 static unsigned int work_nesting_level = 0;
 
-/* Process one switch - called by toplev.c.  */
-
+/* Process a switch - called by opts.c.  */
 int
-treelang_decode_option (num_options_left, first_option_left)
-     int num_options_left ATTRIBUTE_UNUSED; 
-     char** first_option_left;
+treelang_handle_option (size_t scode, const char *arg ATTRIBUTE_UNUSED,
+                       int value)
 {
-  
-  /*
-    Process options - bear in mind I may get options that are really
-    meant for someone else (eg the main compiler) so I have to be very
-    permissive. 
-    
-  */
-  
-  if (first_option_left[0][0] != '-')
-    return 0; 
-  
-  switch (first_option_left[0][1]) 
-    {
-    case '-':
-      if (!strcmp (first_option_left[0],"--help"))
-        {
-          if (!version_done)
-            {
-              fputs (language_string, stdout);
-              fputs (version_string, stdout);
-              fputs ("\n", stdout);
-              version_done = 1;
-            }
-          fprintf (stdout, "Usage: tree1 [switches] -o output input\n");
-          return 1;
-        }
-      break;
+  enum opt_code code = (enum opt_code) scode;
 
-    case 'v':
-      if (!strcmp (first_option_left[0],"-v"))
-        {
-          if (!version_done)
-            {
-              fputs (language_string, stdout);
-              fputs (version_string, stdout);
-              fputs ("\n", stdout);
-              version_done = 1;
-            }
-          return 1;
-        }
-      break;
+  switch (code)
+    {
+    default:
+      return 0;
 
-    case 'y':
-      if (!strcmp (first_option_left[0],"-y"))
-        {
-          option_lexer_trace = 1;
-          option_parser_trace = 1;
-          return 1;
-        }
+    case OPT__help:
+      if (!version_done)
+       {
+         fputs (language_string, stdout);
+         fputs (version_string, stdout);
+         fputs ("\n", stdout);
+         version_done = 1;
+       }
+      fprintf (stdout, "Usage: tree1 [switches] -o output input\n");
       break;
 
-    case 'f':
-      if (!strcmp (first_option_left[0],"-fparser-trace"))
-        {
-          option_parser_trace = 1;
-          return 1;
-        }
-      if (!strcmp (first_option_left[0],"-flexer-trace"))
-        {
-          option_lexer_trace = 1;
-          return 1;
-        }
+    case OPT_v:
+      if (!version_done)
+       {
+         fputs (language_string, stdout);
+         fputs (version_string, stdout);
+         fputs ("\n", stdout);
+         version_done = 1;
+       }
       break;
 
-    case 'w':
-      if (!strcmp (first_option_left[0],"-w"))
-        {
-          /* Tolerate this option but ignore it - we always put out
-             all warnings.  */
-          return 1;
-        }
+    case OPT_y:
+      option_lexer_trace = 1;
+      option_parser_trace = 1;
       break;
 
-    case 'W':
-      if (!strcmp (first_option_left[0],"-Wall"))
-        {
-          return 1;
-        }
+    case OPT_fparser_trace:
+      option_parser_trace = value;
       break;
 
-    default:
+    case OPT_flexer_trace:
+      option_lexer_trace = value;
       break;
     }
 
-  return 0;
+  return 1;
 }
 
 /* Language dependent parser setup.  */
index ca50df4f82064f2f0b915f413c96eae4991e23ba..904616dbcd2e49c0e2907d251244401617ecf7ed 100644 (file)
@@ -114,8 +114,8 @@ extern char **file_names;
 #define LANG_HOOKS_NAME        "GNU treelang"
 #undef LANG_HOOKS_FINISH
 #define LANG_HOOKS_FINISH              treelang_finish
-#undef LANG_HOOKS_DECODE_OPTION
-#define LANG_HOOKS_DECODE_OPTION treelang_decode_option
+#undef LANG_HOOKS_HANDLE_OPTION
+#define LANG_HOOKS_HANDLE_OPTION treelang_handle_option
 const struct lang_hooks lang_hooks = LANG_HOOKS_INITIALIZER;
 
 /* Tree code type/name/code tables.  */
index f2d6e30957fd425f6faa90f2d09317957fc83bb7..c87b3af4da6a741f592ff6da27de5d15fbf367d9 100644 (file)
@@ -63,7 +63,7 @@ tree tree_code_get_type (int type_num);
 void treelang_init_decl_processing (void);
 void treelang_finish (void);
 bool treelang_init (void);
-int treelang_decode_option (int, char **);
+int treelang_handle_option (size_t scode, const char *arg, int value);
 void treelang_parse_file (int debug_flag);
 void push_var_level (void);
 void pop_var_level (void);