Makefile.in (OJBS, c-opts.o): Update.
authorNeil Booth <neil@daikokuya.co.uk>
Sat, 7 Jun 2003 11:10:46 +0000 (11:10 +0000)
committerNeil Booth <neil@gcc.gnu.org>
Sat, 7 Jun 2003 11:10:46 +0000 (11:10 +0000)
* Makefile.in (OJBS, c-opts.o): Update.
(c-options.c, c-options.h): Rename options.h and options.c.
(options.h): Rename options_.h.
(opts.o): New.
* c-common.h (c_common_handle_option): Replace c_common_decode_option.
(c_common_init_options): Update prototype.
* c-lang.c (c_init_options): Update prototype.
(LANG_HOOKS_HANDLE_OPTION): Override.
(LANG_HOOKS_DECODE_OPTION): Drop.
* c-opts.c: Include opts.h and options.h instead of c-options.h
and c-options.c.
(lang_flags): Move to file scope.
(find_opt, c_common_decode_option): Remove.
(CL_C, CL_OBJC, CL_CXX, CL_OBJCXX, CL_JOINED, CL_SEPARATE,
CL_REJECT_NEGATIVE): Move to opts.h.
(missing_arg): Update prototype.
(c_common_init_options): Update for new prototype.
(c_common_handle_options): Filenames are passed as N_OPTS.
* hooks.c (hook_int_void_0): New.
* hooks.h (hook_int_void_0): New.
* langhooks-def.h (LANG_HOOKS_INIT_OPTIONS): New default.
(LANG_HOOKS_HANDLE_OPTION): Default to NULL for now.
(LANG_HOOKS_INITIALIZER): Update.
* langhooks.h (init_options): Update.
(handle_option): New.
* opts.c, opts.h: New files.
* opts.sh: Update c file to include opts.h and options.h.
* toplev.c: Include opts.h; change options.h to options_.h.
(parse_options_and_default_flags): Get lang_mask, use
handle_option for language-specific handling.
* objc/objc-lang.c (LANG_HOOKS_DECODE_OPTON): Drop.
(LANG_HOOKS_HANDLE_OPTION): Override.
(objc_init_options): Update.
ada:
* misc.c (gnat_init_options): Update.
cp:
* cp-lang.c (LANG_HOOKS_DECODE_OPTON): Drop.
(LANG_HOOKS_HANDLE_OPTION): Override.
* cp-tree.h (cxx_init_options): Update.
* lex.c (cxx_init_options): Update.
f:
* com.c (ffe_init_options): Update.
java:
* lang.c (java_init_options): Update.

From-SVN: r67584

24 files changed:
gcc/ChangeLog
gcc/Makefile.in
gcc/ada/ChangeLog
gcc/ada/misc.c
gcc/c-common.h
gcc/c-lang.c
gcc/c-opts.c
gcc/cp/ChangeLog
gcc/cp/cp-lang.c
gcc/cp/cp-tree.h
gcc/cp/lex.c
gcc/f/ChangeLog
gcc/f/com.c
gcc/hooks.c
gcc/hooks.h
gcc/java/ChangeLog
gcc/java/lang.c
gcc/langhooks-def.h
gcc/langhooks.h
gcc/objc/objc-lang.c
gcc/opts.c [new file with mode: 0644]
gcc/opts.h [new file with mode: 0644]
gcc/opts.sh
gcc/toplev.c

index 70c94414f973862433962d22437d00a4e21c8ae5..77210d955303fe6ff5d28133a44372da4178640f 100644 (file)
@@ -1,3 +1,39 @@
+2003-06-07  Neil Booth  <neil@daikokuya.co.uk>
+
+       * Makefile.in (OJBS, c-opts.o): Update.
+       (c-options.c, c-options.h): Rename options.h and options.c.
+       (options.h): Rename options_.h.
+       (opts.o): New.
+       * c-common.h (c_common_handle_option): Replace c_common_decode_option.
+       (c_common_init_options): Update prototype.
+       * c-lang.c (c_init_options): Update prototype.
+       (LANG_HOOKS_HANDLE_OPTION): Override.
+       (LANG_HOOKS_DECODE_OPTION): Drop.
+       * c-opts.c: Include opts.h and options.h instead of c-options.h
+       and c-options.c.
+       (lang_flags): Move to file scope.
+       (find_opt, c_common_decode_option): Remove.
+       (CL_C, CL_OBJC, CL_CXX, CL_OBJCXX, CL_JOINED, CL_SEPARATE,
+       CL_REJECT_NEGATIVE): Move to opts.h.
+       (missing_arg): Update prototype.
+       (c_common_init_options): Update for new prototype.
+       (c_common_handle_options): Filenames are passed as N_OPTS.
+       * hooks.c (hook_int_void_0): New.
+       * hooks.h (hook_int_void_0): New.
+       * langhooks-def.h (LANG_HOOKS_INIT_OPTIONS): New default.
+       (LANG_HOOKS_HANDLE_OPTION): Default to NULL for now.
+       (LANG_HOOKS_INITIALIZER): Update.
+       * langhooks.h (init_options): Update.
+       (handle_option): New.
+       * opts.c, opts.h: New files.
+       * opts.sh: Update c file to include opts.h and options.h.
+       * toplev.c: Include opts.h; change options.h to options_.h.
+       (parse_options_and_default_flags): Get lang_mask, use
+       handle_option for language-specific handling.
+       * objc/objc-lang.c (LANG_HOOKS_DECODE_OPTON): Drop.
+       (LANG_HOOKS_HANDLE_OPTION): Override.
+       (objc_init_options): Update.
+
 2003-06-07  Magnus Kreth <magnus.kreth@gmx.de>
            Thibaud Gaillard <thibaud.gaillard@nto.atmel.com>
 
index a9a9065cd0a51afd778e6b4e6ceb6216212f3364..c92a4c7356c75dd088fa6dc80a8c7d143f6ac88a 100644 (file)
@@ -812,7 +812,8 @@ OBJS = alias.o bb-reorder.o bitmap.o builtins.o caller-save.o calls.o          \
  haifa-sched.o hashtable.o hooks.o ifcvt.o insn-attrtab.o insn-emit.o     \
  insn-extract.o insn-opinit.o insn-output.o insn-peep.o insn-recog.o      \
  integrate.o intl.o jump.o  langhooks.o lcm.o lists.o local-alloc.o       \
- loop.o mbchar.o optabs.o params.o predict.o print-rtl.o print-tree.o     \
+ loop.o mbchar.o optabs.o options.o opts.o params.o predict.o             \
+ print-rtl.o print-tree.o                                                 \
  profile.o ra.o ra-build.o ra-colorize.o ra-debug.o ra-rewrite.o          \
  real.o recog.o reg-stack.o regclass.o regmove.o regrename.o              \
  reload.o reload1.o reorg.o resource.o rtl.o rtlanal.o rtl-error.o        \
@@ -1316,15 +1317,14 @@ c-pretty-print.o : c-pretty-print.c c-pretty-print.h pretty-print.h \
 
 c-opts.o : c-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
         c-pragma.h flags.h toplev.h langhooks.h tree-inline.h diagnostic.h \
-       intl.h debug.h $(C_COMMON_H) c-options.h c-options.c
+       intl.h debug.h $(C_COMMON_H) opts.h options.h
        $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
                $< $(OUTPUT_OPTION) @TARGET_SYSTEM_ROOT_DEFINE@
 
-c-options.c: c.opt $(srcdir)/opts.sh
-       AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh c-options.c c-options.h $(srcdir)/c.opt
+options.c: c.opt $(srcdir)/opts.sh options.h
 
-c-options.h: c-options.c
-       @true
+options.h: c.opt $(srcdir)/opts.sh
+       AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh options.c options.h $(srcdir)/c.opt
 
 c-cppbuiltin.o : c-cppbuiltin.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
        $(TREE_H) $(C_COMMON_H) c-pragma.h flags.h toplev.h langhooks.h \
@@ -1404,12 +1404,12 @@ s-gencheck : Makefile
        $(SHELL) $(srcdir)/move-if-change tmp-gencheck.h gencheck.h
        $(STAMP) s-gencheck
 
-options.h : s-options ; @true
+options_.h : s-options ; @true
 s-options : Makefile
        lof="$(lang_options_files)"; for f in $$lof; do \
            echo "#include \"$$f\""; \
-       done | sed 's|$(srcdir)/||' > tmp-options.h
-       $(SHELL) $(srcdir)/move-if-change tmp-options.h options.h
+       done | sed 's|$(srcdir)/||' > tmp-options_.h
+       $(SHELL) $(srcdir)/move-if-change tmp-options_.h options_.h
        $(STAMP) s-options
 
 specs.h : s-specs ; @true
@@ -1479,13 +1479,15 @@ fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H
 diagnostic.o : diagnostic.c diagnostic.h real.h diagnostic.def \
    $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(TM_P_H) flags.h $(GGC_H) \
    input.h toplev.h intl.h langhooks.h $(LANGHOOKS_DEF_H)
+opts.o : opts.c opts.h options.h $(CONFIG_H) $(SYSTEM_H) \
+       coretypes.h $(TREE_H) $(TM_H) $(LANGHOOKS_H)
 toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
    function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h diagnostic.h \
    debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \
    dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
    graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) \
    ssa.h $(PARAMS_H) $(TM_P_H) reload.h dwarf2asm.h $(TARGET_H) \
-   langhooks.h insn-flags.h options.h cfglayout.h real.h cfgloop.h \
+   langhooks.h insn-flags.h options_.h cfglayout.h real.h cfgloop.h \
    hosthooks.h $(LANGHOOKS_DEF_H) cgraph.h
        $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
          -DTARGET_NAME=\"$(target_alias)\" \
@@ -2785,7 +2787,7 @@ mostlyclean: $(INTL_MOSTLYCLEAN) lang.mostlyclean
        -rm -f xlimits.h
 # Delete other built files.
        -rm -f xsys-protos.hT
-       -rm -f specs.h options.h gencheck.h c-options.c c-options.h
+       -rm -f specs.h options_.h gencheck.h options.c options.h
 # Delete the stamp and temporary files.
        -rm -f s-* tmp-* stamp-* stmp-*
        -rm -f */stamp-* */tmp-*
index 628a941976976f56be8419861a3e5e1d06bad03a..2a584d0d20ce21ad5728093ec4a9ef49739d6eba 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-07  Neil Booth  <neil@daikokuya.co.uk>
+
+       * misc.c (gnat_init_options): Update.
+
 2003-06-05  Matt Kraai  <kraai@alumni.cmu.edu>
 
        * Make-lang.in (ada/b_gnatb.o-warn): Remove.
index 93a52eb338afe22a807915d1416b0f19280109c2..180bb9a60f9a51a19da74160a2a90e7ab1ed5db0 100644 (file)
@@ -81,7 +81,7 @@ extern char **save_argv;
 
 static size_t gnat_tree_size           PARAMS ((enum tree_code));
 static bool gnat_init                  PARAMS ((void));
-static void gnat_init_options          PARAMS ((void));
+static int gnat_init_options           PARAMS ((void));
 static int gnat_decode_option          PARAMS ((int, char **));
 static HOST_WIDE_INT gnat_get_alias_set        PARAMS ((tree));
 static void gnat_print_decl            PARAMS ((FILE *, tree, int));
@@ -300,13 +300,15 @@ gnat_decode_option (argc, argv)
 
 /* Initialize for option processing.  */
 
-static void
+static int
 gnat_init_options ()
 {
   /* Initialize gnat_argv with save_argv size */
   gnat_argv = (char **) xmalloc ((save_argc + 1) * sizeof (gnat_argv[0])); 
   gnat_argv[0] = save_argv[0];     /* name of the command */ 
   gnat_argc = 1;
+
+  return 0;
 }
 
 /* Here is the function to handle the compiler error processing in GCC.  */
index 4f82b8f07035e14c90c90c8447873433a7af3df2..b458afcf4ceeac3dc8d36d4d09cce763b5e3e2de 100644 (file)
@@ -901,7 +901,7 @@ extern tree handle_format_attribute         PARAMS ((tree *, tree, tree,
 extern tree handle_format_arg_attribute                PARAMS ((tree *, tree, tree,
                                                         int, bool *));
 extern void c_common_insert_default_attributes PARAMS ((tree));
-extern int c_common_decode_option              PARAMS ((int, char **));
+extern int c_common_handle_option (size_t code, const char *arg, int value);
 extern tree c_common_type_for_mode             PARAMS ((enum machine_mode,
                                                         int));
 extern tree c_common_type_for_size             PARAMS ((unsigned int, int));
@@ -959,7 +959,7 @@ extern void disable_builtin_function                PARAMS ((const char *));
 
 extern tree build_va_arg                       PARAMS ((tree, tree));
 
-extern void c_common_init_options              PARAMS ((enum c_language_kind));
+extern int c_common_init_options               PARAMS ((enum c_language_kind));
 extern bool c_common_post_options              PARAMS ((const char **));
 extern bool c_common_init                      PARAMS ((void));
 extern void c_common_finish                    PARAMS ((void));
index 116561e9d0723a033c14517aef7362139910dde4..92b9c6e4b28f689b4a8c72b135a35874c9af1154 100644 (file)
@@ -31,7 +31,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "langhooks.h"
 #include "langhooks-def.h"
 
-static void c_init_options PARAMS ((void));
+static int c_init_options PARAMS ((void));
 
 /* ### When changing hooks, consider if ObjC needs changing too!! ### */
 
@@ -43,8 +43,8 @@ static void c_init_options PARAMS ((void));
 #define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS c_init_options
-#undef LANG_HOOKS_DECODE_OPTION
-#define LANG_HOOKS_DECODE_OPTION c_common_decode_option
+#undef LANG_HOOKS_HANDLE_OPTION
+#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
@@ -157,10 +157,10 @@ const char *const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
-static void
+static int
 c_init_options ()
 {
-  c_common_init_options (clk_c);
+  return c_common_init_options (clk_c);
 }
 
 /* Used by c-lex.c, but only for objc.  */
index 1dd59669aa5bf0cc1f821dd670a37a7e7f3157fe..75078b5d5cfcd92089c2a25abf3db98ffdbe4faa 100644 (file)
@@ -35,7 +35,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cppdefault.h"
 #include "c-incpath.h"
 #include "debug.h"             /* For debug_hooks.  */
-#include "c-options.h"
+#include "opts.h"
+#include "options.h"
 
 #ifndef DOLLARS_IN_IDENTIFIERS
 # define DOLLARS_IN_IDENTIFIERS true
@@ -49,6 +50,8 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 # define TARGET_EBCDIC 0
 #endif
 
+static const int lang_flags[] = {CL_C, CL_OBJC, CL_CXX, CL_OBJCXX};
+
 static int saved_lineno;
 
 /* CPP's options.  */
@@ -97,8 +100,7 @@ static size_t deferred_count, deferred_size;
 /* Number of deferred options scanned for -include.  */
 static size_t include_cursor;
 
-static void missing_arg PARAMS ((size_t));
-static size_t find_opt PARAMS ((const char *, int));
+static void missing_arg PARAMS ((enum opt_code));
 static void set_Wimplicit PARAMS ((int));
 static void complain_wrong_lang PARAMS ((size_t));
 static void write_langs PARAMS ((char *, int));
@@ -114,36 +116,12 @@ static void add_prefixed_path PARAMS ((const char *, size_t));
 static void push_command_line_include PARAMS ((void));
 static void cb_file_change PARAMS ((cpp_reader *, const struct line_map *));
 static void finish_options PARAMS ((void));
-static int c_common_handle_option (enum opt_code, const char *arg, int on);
 
 #ifndef STDC_0_IN_SYSTEM_HEADERS
 #define STDC_0_IN_SYSTEM_HEADERS 0
 #endif
 
-#define CL_C                   (1 << 0) /* Only C.  */
-#define CL_OBJC                        (1 << 1) /* Only ObjC.  */
-#define CL_CXX                 (1 << 2) /* Only C++.  */
-#define CL_OBJCXX              (1 << 3) /* Only ObjC++.  */
-#define CL_JOINED              (1 << 4) /* If takes joined argument.  */
-#define CL_SEPARATE            (1 << 5) /* If takes a separate argument.  */
-#define CL_REJECT_NEGATIVE     (1 << 6) /* Reject no- form.  */
-
-#include "c-options.c"
-
-/* If the user gives an option to a front end that doesn't support it,
-   an error is output, mentioning which front ends the option is valid
-   for.  If you don't want this, you must accept it for all front
-   ends, and test for the front end in the option handler.  See, for
-   example, the handling of -fcond-mismatch.
-
-   If you requested a joined or separate argument, it is stored in the
-   variable "arg", which is guaranteed to be non-NULL and to not be an
-   empty string.  It points to the argument either within the argv[]
-   vector or within one of that vector's strings, and so the text is
-   permanent and copies need not be made.  Be sure to add an error
-   message in missing_arg() if the default is not appropriate.  */
-
-/* Holds switches parsed by c_common_decode_option (), but whose
+/* Holds switches parsed by c_common_handle_option (), but whose
    handling is deferred to c_common_post_options ().  */
 static void defer_opt PARAMS ((enum opt_code, const char *));
 static struct deferred_opt
@@ -155,12 +133,11 @@ static struct deferred_opt
 /* Complain that switch OPT_INDEX expects an argument but none was
    provided.  */
 static void
-missing_arg (opt_index)
-     size_t opt_index;
+missing_arg (enum opt_code code)
 {
-  const char *opt_text = cl_options[opt_index].opt_text;
+  const char *opt_text = cl_options[code].opt_text;
 
-  switch (opt_index)
+  switch (code)
     {
     case OPT__output_pch_:
     case OPT_Wformat_:
@@ -214,95 +191,6 @@ missing_arg (opt_index)
     }
 }
 
-/* Perform a binary search to find which option the command-line INPUT
-   matches.  Returns its index in the option array, and N_OPTS on
-   failure.
-
-   Complications arise since some options can be suffixed with an
-   argument, and multiple complete matches can occur, e.g. -pedantic
-   and -pedantic-errors.  Also, some options are only accepted by some
-   languages.  If a switch matches for a different language and
-   doesn't match any alternatives for the true front end, the index of
-   the matched switch is returned anyway.  The caller should check for
-   this case.  */
-static size_t
-find_opt (input, lang_flag)
-     const char *input;
-     int lang_flag;
-{
-  size_t md, mn, mx;
-  size_t opt_len;
-  size_t result = N_OPTS;
-  int comp;
-
-  mn = 0;
-  mx = N_OPTS;
-
-  while (mx > mn)
-    {
-      md = (mn + mx) / 2;
-
-      opt_len = cl_options[md].opt_len;
-      comp = strncmp (input, cl_options[md].opt_text, opt_len);
-
-      if (comp < 0)
-       mx = md;
-      else if (comp > 0)
-       mn = md + 1;
-      else
-       {
-         /* The switch matches.  It it an exact match?  */
-         if (input[opt_len] == '\0')
-           return md;
-         else
-           {
-             mn = md + 1;
-
-             /* If the switch takes no arguments this is not a proper
-                match, so we continue the search (e.g. input="stdc++"
-                match was "stdc").  */
-             if (!(cl_options[md].flags & CL_JOINED))
-               continue;
-
-             /* Is this switch valid for this front end?  */
-             if (!(cl_options[md].flags & lang_flag))
-               {
-                 /* If subsequently we don't find a better match,
-                    return this and let the caller report it as a bad
-                    match.  */
-                 result = md;
-                 continue;
-               }
-
-             /* Two scenarios remain: we have the switch's argument,
-                or we match a longer option.  This can happen with
-                -iwithprefix and -withprefixbefore.  The longest
-                possible option match succeeds.
-
-                Scan forwards, and return an exact match.  Otherwise
-                return the longest valid option-accepting match (mx).
-                This loops at most twice with current options.  */
-             mx = md;
-             for (md = md + 1; md < (size_t) N_OPTS; md++)
-               {
-                 opt_len = cl_options[md].opt_len;
-                 if (strncmp (input, cl_options[md].opt_text, opt_len))
-                   break;
-                 if (input[opt_len] == '\0')
-                   return md;
-                 if (cl_options[md].flags & lang_flag
-                     && cl_options[md].flags & CL_JOINED)
-                   mx = md;
-               }
-
-             return mx;
-           }
-       }
-    }
-
-  return result;
-}
-
 /* Defer option CODE with argument ARG.  */
 static void
 defer_opt (code, arg)
@@ -328,7 +216,7 @@ defer_opt (code, arg)
 }
 
 /* Common initialization before parsing options.  */
-void
+int
 c_common_init_options (lang)
      enum c_language_kind lang;
 {
@@ -342,134 +230,50 @@ c_common_init_options (lang)
 
   flag_const_strings = (lang == clk_cplusplus);
   warn_pointer_arith = (lang == clk_cplusplus);
+
+  return lang_flags[(c_language << 1) + flag_objc];
 }
 
-/* Handle one command-line option in (argc, argv).
-   Can be called multiple times, to handle multiple sets of options.
-   Returns number of strings consumed.  */
+/* Handle switch SCODE with argument ARG.  ON is true, unless no-
+   form of an -f or -W option was given.  Returns 0 if the switch was
+   invalid, a negative number to prevent language-independent
+   processing in toplev.c (a hack necessary for the short-term).  */
 int
-c_common_decode_option (argc, argv)
-     int argc;
-     char **argv;
+c_common_handle_option (size_t scode, const char *arg, int on)
 {
-  static const int lang_flags[] = {CL_C, CL_OBJC, CL_CXX, CL_OBJCXX};
-  size_t opt_index;
-  const char *opt, *arg = 0;
-  char *dup = 0;
-  bool on = true;
-  int result = 0, temp, lang_flag;
-  const struct cl_option *option;
-
-  opt = argv[0];
-
-  /* Interpret "-" or a non-switch as a file name.  */
-  if (opt[0] != '-' || opt[1] == '\0')
+  const struct cl_option *option = &cl_options[scode];
+  enum opt_code code = (enum opt_code) scode;
+  int result = 1, lang_mask;
+
+  if (code == N_OPTS)
     {
       if (!in_fname)
-       in_fname = opt;
+       in_fname = arg;
       else if (!out_fname)
-       out_fname = opt;
+       out_fname = arg;
       else
-       {
          error ("too many filenames given.  Type %s --help for usage",
                 progname);
-         return argc;
-       }
-
       return 1;
     }
 
-  /* Drop the "no-" from negative switches.  */
-  if ((opt[1] == 'W' || opt[1] == 'f')
-      && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
-    {
-      size_t len = strlen (opt) - 3;
-
-      dup = xmalloc (len + 1);
-      dup[0] = '-';
-      dup[1] = opt[1];
-      memcpy (dup + 2, opt + 5, len - 2 + 1);
-      opt = dup;
-      on = false;
-    }
-
-  /* Skip over '-'.  */
-  lang_flag = lang_flags[(c_language << 1) + flag_objc];
-  opt_index = find_opt (opt + 1, lang_flag);
-  if (opt_index == N_OPTS)
-    goto done;
-
-  option = &cl_options[opt_index];
-
-  /* Reject negative form of switches that don't take negatives.  */
-  if (!on && (option->flags & CL_REJECT_NEGATIVE))
-    goto done;
-
-  /* We've recognised this switch.  */
-  result = 1;
-
-  /* Sort out any argument the switch takes.  */
-  if (option->flags & (CL_JOINED | CL_SEPARATE))
+  lang_mask = lang_flags[(c_language << 1) + flag_objc];
+  if (!(option->flags & lang_mask))
     {
-      if (option->flags & CL_JOINED)
-       {
-         /* Have arg point to the original switch.  This is because
-            some code, such as disable_builtin_function, expects its
-            argument to be persistent until the program exits.  */
-         arg = argv[0] + cl_options[opt_index].opt_len + 1;
-         if (!on)
-           arg += strlen ("no-");
-       }
-
-      /* If we don't have an argument, and CL_SEPARATE, try the next
-        argument in the vector.  */
-      if (!arg || (*arg == '\0' && option->flags & CL_SEPARATE))
-       {
-         arg = argv[1];
-         result = 2;
-       }
-
-      if (!arg || *arg == '\0')
-       {
-         missing_arg (opt_index);
-         result = argc;
-         goto done;
-       }
+      complain_wrong_lang (code);
+      return 1;
     }
 
-  /* Complain about the wrong language after we've swallowed any
-     necessary extra argument.  Eventually make this a hard error
-     after the call to find_opt, and return argc.  */
-  if (!(cl_options[opt_index].flags & lang_flag))
+  if (arg == NULL && (option->flags & (CL_JOINED | CL_SEPARATE)))
     {
-      complain_wrong_lang (opt_index);
-      goto done;
+      missing_arg (code);
+      return 1;
     }
 
-  temp = c_common_handle_option (opt_index, arg, on);
-  if (temp <= 0)
-    result = temp;
-
- done:
-  if (dup)
-    free (dup);
-  return result;
-}
-
-/* Handle switch OPT_INDEX with argument ARG.  ON is true, unless no-
-   form of an -f or -W option was given.  Returns 0 if the switch was
-   invalid, a negative number to prevent language-independent
-   processing in toplev.c (a hack necessary for the short-term).  */
-static int
-c_common_handle_option (enum opt_code code, const char *arg, int on)
-{
-  const struct cl_option *option = &cl_options[code];
-  int result = 1;
-
   switch (code)
     {
-    case N_OPTS: /* Shut GCC up.  */
-      break;
+    default:
+      return 0;
 
     case OPT__help:
       print_help ();
@@ -1740,6 +1544,7 @@ complain_wrong_lang (opt_index)
 
   write_langs (ok_langs, ok_flags);
   write_langs (bad_langs, ~ok_flags);
+  /* Eventually this should become a hard error.  */
   warning ("\"-%s\" is valid for %s but not for %s",
           cl_options[opt_index].opt_text, ok_langs, bad_langs);
 }
index e27e188a691246d0b4e26876825561e65dcc5899..59109315b70c4c00039f6b038bb0ad5e94becbfd 100644 (file)
@@ -1,3 +1,10 @@
+2003-06-07  Neil Booth  <neil@daikokuya.co.uk>
+
+       * cp-lang.c (LANG_HOOKS_DECODE_OPTON): Drop.
+       (LANG_HOOKS_HANDLE_OPTION): Override.
+       * cp-tree.h (cxx_init_options): Update.
+       * lex.c (cxx_init_options): Update.
+
 Thu Jun  5 18:33:40 CEST 2003  Jan Hubicka  <jh@suse.cz>
 
        * Make-lang.in:  Add support for stageprofile and stagefeedback
index 0caa3360a77ad22c50bf7c093b67ba2411a1beee..7914d81c5f6f07a8af794e83e038e726983afcbf 100644 (file)
@@ -49,8 +49,8 @@ static bool cp_var_mod_type_p (tree);
 #define LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS cxx_init_options
-#undef LANG_HOOKS_DECODE_OPTION
-#define LANG_HOOKS_DECODE_OPTION c_common_decode_option
+#undef LANG_HOOKS_HANDLE_OPTION
+#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
index b72fb1787f3076c643705476b73b42a906720ac5..5b815fe82b7efd2d69b83ef6cf7726291d249940 100644 (file)
@@ -3898,7 +3898,7 @@ extern void yyhook                                (int);
 extern int cp_type_qual_from_rid                (tree);
 extern bool cxx_init                           (void);
 extern void cxx_finish (void);
-extern void cxx_init_options (void);
+extern int cxx_init_options (void);
 
 /* in method.c */
 extern void init_method        (void);
index 816f9e38c77f7169c8c058566db27278694cefe1..27684527f32e4575bc84a7345245d34a29a9b66d 100644 (file)
@@ -150,11 +150,9 @@ int interface_unknown;             /* whether or not we know this class
 
 \f
 /* Initialization before switch parsing.  */
-void
+int
 cxx_init_options ()
 {
-  c_common_init_options (clk_cplusplus);
-
   /* Default exceptions on.  */
   flag_exceptions = 1;
   /* By default wrap lines at 80 characters.  Is getenv ("COLUMNS")
@@ -163,6 +161,8 @@ cxx_init_options ()
   /* By default, emit location information once for every
      diagnostic message.  */
   diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
+
+  return c_common_init_options (clk_cplusplus);
 }
 
 void
index 0ff9f992ad77f4bd36a912d127193bed9d502ebb..9baac574ffd225e0dcc6254c17afcf7b4178e0cb 100644 (file)
@@ -1,3 +1,7 @@
+Sat Jun  7 12:10:41 2003  Neil Booth  <neil@daikokuya.co.uk>
+
+       * com.c (ffe_init_options): Update.
+
 Thu Jun  5 18:33:40 CEST 2003  Jan Hubicka  <jh@suse.cz>
 
        * Make-lang.in:  Add support for stageprofile and stagefeedback
index fb90a46efa0e1e3fa52fa4f01ee52932d50d2545..c0902c5f99efba8f7201185620c088d1697f02f2 100644 (file)
@@ -14149,7 +14149,7 @@ insert_block (tree block)
 static bool ffe_init PARAMS ((void));
 static void ffe_finish PARAMS ((void));
 static bool ffe_post_options PARAMS ((const char **));
-static void ffe_init_options PARAMS ((void));
+static int ffe_init_options PARAMS ((void));
 static void ffe_print_identifier PARAMS ((FILE *, tree, int));
 
 struct language_function GTY(())
@@ -14289,7 +14289,7 @@ ffe_finish ()
   fclose (finput);
 }
 
-static void
+static int
 ffe_init_options ()
 {
   /* Set default options for Fortran.  */
@@ -14299,6 +14299,8 @@ ffe_init_options ()
   flag_merge_constants = 2;
   flag_errno_math = 0;
   flag_complex_divide_method = 1;
+
+  return 0;
 }
 
 static bool
index 1ec672585c2d76446a4ded4d06cf063af3eba2e2..a80ded7fc41df23b970a4275919414f27a8d0c12 100644 (file)
@@ -104,6 +104,12 @@ hook_int_rtx_0 (a)
   return 0;
 }
 
+int
+hook_int_void_0 (void)
+{
+  return 0;
+}
+
 void
 hook_void_tree (a)
      tree a ATTRIBUTE_UNUSED;
index 5866da71bc90364a23a1354f3bf64670964e6ee1..407440fe33188b18f82b71247c7fade131d2fac8 100644 (file)
@@ -39,6 +39,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);
 
 bool default_can_output_mi_thunk_no_vcall
   PARAMS ((tree, HOST_WIDE_INT, HOST_WIDE_INT, tree));
index 2c6d3f9c573a769f9190d8a171cea814c70a1dca..f06a3c675acf4c3664d4e618ac153c166ec17ad4 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-07  Neil Booth  <neil@daikokuya.co.uk>
+
+       * lang.c (java_init_options): Update.
+
 Thu Jun  5 18:33:40 CEST 2003  Jan Hubicka  <jh@suse.cz>
 
        * Make-lang.in:  Add support for stageprofile and stagefeedback
index 918be0a5d7d5c04b8fd2ea350176f51a957087e9..28be548e8879d48b53b5c5fee3e81d30aeb53b2d 100644 (file)
@@ -55,7 +55,7 @@ struct string_option
 
 static bool java_init (void);
 static void java_finish (void);
-static void java_init_options (void);
+static int java_init_options (void);
 static bool java_post_options (const char **);
 
 static int java_decode_option (int, char **);
@@ -731,7 +731,7 @@ void lang_init_source (int level)
   inhibit_error_function_printing = (level == 1);
 }
 
-static void
+static int
 java_init_options (void)
 {
   flag_bounds_check = 1;
@@ -743,6 +743,8 @@ java_init_options (void)
 
   /* In Java arithmetic overflow always wraps around.  */
   flag_wrapv = 1;
+
+  return 0;
 }
 
 static bool
index 1c2244a6276e7bcc41682ea5fcc0e1ec4a62b917..5a752bed119d9efae7a82e0abbd44241fa20483d 100644 (file)
@@ -92,8 +92,9 @@ void write_global_declarations PARAMS ((void));
 #define LANG_HOOKS_FINISH              lhd_do_nothing
 #define LANG_HOOKS_PARSE_FILE          lhd_do_nothing_i
 #define LANG_HOOKS_CLEAR_BINDING_STACK lhd_clear_binding_stack
-#define LANG_HOOKS_INIT_OPTIONS                lhd_do_nothing
+#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_POST_OPTIONS                lhd_post_options
 #define LANG_HOOKS_GET_ALIAS_SET       lhd_get_alias_set
 #define LANG_HOOKS_EXPAND_CONSTANT     lhd_return_tree
@@ -243,6 +244,7 @@ int lhd_tree_dump_type_quals                        PARAMS ((tree));
   LANG_HOOKS_TREE_SIZE, \
   LANG_HOOKS_INIT_OPTIONS, \
   LANG_HOOKS_DECODE_OPTION, \
+  LANG_HOOKS_HANDLE_OPTION, \
   LANG_HOOKS_POST_OPTIONS, \
   LANG_HOOKS_INIT, \
   LANG_HOOKS_FINISH, \
index 70ad952b6f3fbc394b5e7c24e6c526d9437d6e99..c3ec11ddbb32f993be5a95889dcea1b0f1ef2547 100644 (file)
@@ -199,8 +199,9 @@ struct lang_hooks
   size_t (*tree_size) PARAMS ((enum tree_code));
 
   /* The first callback made to the front end, for simple
-     initialization needed before any calls to decode_option.  */
-  void (*init_options) PARAMS ((void));
+     initialization needed before any calls to handle_option.  Return
+     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
@@ -209,9 +210,20 @@ 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.  */
+     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
+     checking whether ARG is NULL, which indicates that no argument
+     was in fact supplied.  For -f and -W switches, VALUE is 1 or 0
+     for the positive and negative forms respectively.
+
+     Return 1 if the switch is valid, 0 if invalid, and -1 if it's
+     valid and should not be treated as language-independent too.  */
+  int (*handle_option) (size_t code, const char *arg, int value);
+
   /* Called when all command line options have been parsed to allow
      further processing and initialization
 
index 686e35e3d66bce7233bca1b0ca7bcd19b250119c..2002840f5fa03154f424db8758bfb34ea7d74ffb 100644 (file)
@@ -31,7 +31,7 @@ Boston, MA 02111-1307, USA.  */
 #include "langhooks.h"
 #include "langhooks-def.h"
 
-static void objc_init_options                   PARAMS ((void));
+static int objc_init_options                   PARAMS ((void));
 
 #undef LANG_HOOKS_NAME
 #define LANG_HOOKS_NAME "GNU Objective-C"
@@ -41,8 +41,8 @@ static void objc_init_options                   PARAMS ((void));
 #define LANG_HOOKS_FINISH c_common_finish
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS objc_init_options
-#undef LANG_HOOKS_DECODE_OPTION
-#define LANG_HOOKS_DECODE_OPTION c_common_decode_option
+#undef LANG_HOOKS_HANDLE_OPTION
+#define LANG_HOOKS_HANDLE_OPTION c_common_handle_option
 #undef LANG_HOOKS_POST_OPTIONS
 #define LANG_HOOKS_POST_OPTIONS c_common_post_options
 #undef LANG_HOOKS_GET_ALIAS_SET
@@ -164,9 +164,9 @@ const char * const tree_code_name[] = {
 };
 #undef DEFTREECODE
 
-static void 
+static int 
 objc_init_options ()
 {
   flag_objc = 1;
-  c_common_init_options (clk_c);
+  return c_common_init_options (clk_c);
 }
diff --git a/gcc/opts.c b/gcc/opts.c
new file mode 100644 (file)
index 0000000..3d3fa10
--- /dev/null
@@ -0,0 +1,209 @@
+/* Command line option handling.
+   Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+   Contributed by Neil Booth.
+
+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.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
+#include "tree.h"
+#include "langhooks.h"
+#include "opts.h"
+#include "options.h"
+
+static enum opt_code find_opt (const char *, int);
+
+/* Perform a binary search to find which option the command-line INPUT
+   matches.  Returns its index in the option array, and N_OPTS on
+   failure.
+
+   Complications arise since some options can be suffixed with an
+   argument, and multiple complete matches can occur, e.g. -pedantic
+   and -pedantic-errors.  Also, some options are only accepted by some
+   languages.  If a switch matches for a different language and
+   doesn't match any alternatives for the true front end, the index of
+   the matched switch is returned anyway.  The caller should check for
+   this case.  */
+static enum opt_code
+find_opt (const char *input, int lang_mask)
+{
+  size_t md, mn, mx;
+  size_t opt_len;
+  enum opt_code result = N_OPTS;
+  int comp;
+
+  mn = 0;
+  mx = N_OPTS;
+
+  while (mx > mn)
+    {
+      md = (mn + mx) / 2;
+
+      opt_len = cl_options[md].opt_len;
+      comp = strncmp (input, cl_options[md].opt_text, opt_len);
+
+      if (comp < 0)
+       mx = md;
+      else if (comp > 0)
+       mn = md + 1;
+      else
+       {
+         /* The switch matches.  It it an exact match?  */
+         if (input[opt_len] == '\0')
+           return md;
+         else
+           {
+             mn = md + 1;
+
+             /* If the switch takes no arguments this is not a proper
+                match, so we continue the search (e.g. input="stdc++"
+                match was "stdc").  */
+             if (!(cl_options[md].flags & CL_JOINED))
+               continue;
+
+             /* Is this switch valid for this front end?  */
+             if (!(cl_options[md].flags & lang_mask))
+               {
+                 /* If subsequently we don't find a better match,
+                    return this and let the caller report it as a bad
+                    match.  */
+                 result = (enum opt_code) md;
+                 continue;
+               }
+
+             /* Two scenarios remain: we have the switch's argument,
+                or we match a longer option.  This can happen with
+                -iwithprefix and -withprefixbefore.  The longest
+                possible option match succeeds.
+
+                Scan forwards, and return an exact match.  Otherwise
+                return the longest valid option-accepting match (mx).
+                This loops at most twice with current options.  */
+             mx = md;
+             for (md = md + 1; md < N_OPTS; md++)
+               {
+                 opt_len = cl_options[md].opt_len;
+                 if (strncmp (input, cl_options[md].opt_text, opt_len))
+                   break;
+                 if (input[opt_len] == '\0')
+                   return md;
+                 if (cl_options[md].flags & lang_mask
+                     && cl_options[md].flags & CL_JOINED)
+                   mx = md;
+               }
+
+             return mx;
+           }
+       }
+    }
+
+  return result;
+}
+
+/* Handle the switch beginning at ARGV, with ARGC remaining.  */
+int
+handle_option (int argc, char **argv, int lang_mask)
+{
+  size_t opt_index;
+  const char *opt, *arg = 0;
+  char *dup = 0;
+  bool on = true;
+  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.  */
+  if (opt[0] != '-' || opt[1] == '\0')
+    {
+      opt_index = N_OPTS;
+      arg = opt;
+      result = 1;
+    }
+  else
+    {
+      /* Drop the "no-" from negative switches.  */
+      if ((opt[1] == 'W' || opt[1] == 'f')
+         && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
+       {
+         size_t len = strlen (opt) - 3;
+
+         dup = xmalloc (len + 1);
+         dup[0] = '-';
+         dup[1] = opt[1];
+         memcpy (dup + 2, opt + 5, len - 2 + 1);
+         opt = dup;
+         on = false;
+       }
+
+      /* Skip over '-'.  */
+      opt_index = find_opt (opt + 1, lang_mask);
+      if (opt_index == N_OPTS)
+       goto done;
+
+      option = &cl_options[opt_index];
+
+      /* Reject negative form of switches that don't take negatives.  */
+      if (!on && (option->flags & CL_REJECT_NEGATIVE))
+       goto done;
+
+      /* We've recognised this switch.  */
+      result = 1;
+
+      /* Sort out any argument the switch takes.  */
+      if (option->flags & (CL_JOINED | CL_SEPARATE))
+       {
+         if (option->flags & CL_JOINED)
+           {
+             /* Have arg point to the original switch.  This is because
+                some code, such as disable_builtin_function, expects its
+                argument to be persistent until the program exits.  */
+             arg = argv[0] + cl_options[opt_index].opt_len + 1;
+             if (!on)
+               arg += strlen ("no-");
+           }
+
+         /* If we don't have an argument, and CL_SEPARATE, try the next
+            argument in the vector.  */
+         if (!arg || (*arg == '\0' && option->flags & CL_SEPARATE))
+           {
+             arg = argv[1];
+             result = 2;
+           }
+
+         /* Canonicalize missing arguments as NULL for the handler.  */
+         if (*arg == '\0')
+           arg = NULL;
+       }
+    }
+
+  temp = (*lang_hooks.handle_option) (opt_index, arg, on);
+  if (temp <= 0)
+    result = temp;
+
+ done:
+  if (dup)
+    free (dup);
+  return result;
+}
diff --git a/gcc/opts.h b/gcc/opts.h
new file mode 100644 (file)
index 0000000..297bd82
--- /dev/null
@@ -0,0 +1,34 @@
+/* Command line option handling.
+   Copyright (C) 2002, 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.  */
+
+#ifndef GCC_OPTS_H
+#define GCC_OPTS_H
+
+extern int handle_option (int argc, char **argv, int lang_mask);
+
+#define CL_C                   (1 << 0) /* Only C.  */
+#define CL_OBJC                        (1 << 1) /* Only ObjC.  */
+#define CL_CXX                 (1 << 2) /* Only C++.  */
+#define CL_OBJCXX              (1 << 3) /* Only ObjC++.  */
+#define CL_JOINED              (1 << 4) /* If takes joined argument.  */
+#define CL_SEPARATE            (1 << 5) /* If takes a separate argument.  */
+#define CL_REJECT_NEGATIVE     (1 << 6) /* Reject no- form.  */
+
+#endif
index 4056946df10912130505ac1cb41dc146f23a8e78..bc90150fcb580f2a3402bd6f1af021e367fd16ce 100644 (file)
@@ -65,9 +65,12 @@ cat "$@" | ${AWK} '
        print "  const char *opt_text;"                 >> h_file
        print "  unsigned char opt_len;"                >> h_file
        print "  unsigned char flags;"                  >> h_file
-       print "};\n"                                    >> h_file
+       print "};\n\n"                                  >> h_file
+       print "extern const struct cl_option cl_options[];\n" >> h_file
        print "enum opt_code\n{"                        >> h_file
-       print "static const struct cl_option cl_options[] =\n{" >> c_file
+       print "#include \"options.h\""                  >> c_file
+       print "#include \"opts.h\"\n"                   >> c_file
+       print "const struct cl_option cl_options[] =\n{" >> c_file
     }
 
     {
index 1a82946a8a683c57b6e5e718c2c79528d0b76a9f..83db268232f5ff146618b4daf1afb1f300540724 100644 (file)
@@ -76,6 +76,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include "cfgloop.h"
 #include "hosthooks.h"
 #include "cgraph.h"
+#include "opts.h"
 
 #if defined (DWARF2_UNWIND_INFO) || defined (DWARF2_DEBUGGING_INFO)
 #include "dwarf2out.h"
@@ -1457,7 +1458,7 @@ documented_lang_options[] =
 
 #define DEFINE_LANG_NAME(NAME) { NULL, NAME },
 
-#include "options.h"
+#include "options_.h"
 
 };
 
@@ -5134,7 +5135,7 @@ general_init (char *argv0)
 static void
 parse_options_and_default_flags (int argc, char **argv)
 {
-  int i;
+  int i, lang_mask;
 
   /* Save in case md file wants to emit args as a comment.  */
   save_argc = argc;
@@ -5150,7 +5151,7 @@ parse_options_and_default_flags (int argc, char **argv)
   init_ggc_heuristics();
 
   /* Perform language-specific options initialization.  */
-  (*lang_hooks.init_options) ();
+  lang_mask = (*lang_hooks.init_options) ();
 
   /* Scan to see what optimization level has been specified.  That will
      determine the default value of many flags.  */
@@ -5287,7 +5288,7 @@ parse_options_and_default_flags (int argc, char **argv)
       int indep_processed;
 
       /* Give the language a chance to decode the option for itself.  */
-      lang_processed = (*lang_hooks.decode_option) (argc - i, argv + i);
+      lang_processed = handle_option (argc - i, argv + i, lang_mask);
 
       if (lang_processed >= 0)
        /* Now see if the option also has a language independent meaning.