* langhooks-def.h (lhd_init_options, LANG_HOOKS_OPTION_LANG_MASK,
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jul 2010 09:59:51 +0000 (09:59 +0000)
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 27 Jul 2010 09:59:51 +0000 (09:59 +0000)
LANG_HOOKS_COMPLAIN_WRONG_LANG_P): New.
(LANG_HOOKS_INIT_OPTIONS): Update default definition.
(LANG_HOOKS_INITIALIZER): Add new hooks.
* langhooks.c (lhd_init_options, lhd_complain_wrong_lang_p): New.
* langhooks.h (struct lang_hooks): Add new hooks option_lang_mask
and complain_wrong_lang_p.  Update init_options prototype.
* c-objc-common.c (c_initialize_diagnostics): First call
c_common_initialize_diagnostics.
* c-objc-common.h (LANG_HOOKS_OPTION_LANG_MASK,
LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define.
* coretypes.h (struct cl_option, struct cl_decoded_option):
Declare.
* hooks.c (hook_uint_uint_constcharptrptr_0): Remove.
(hook_uint_void_0): New.
* hooks.h (hook_uint_uint_constcharptrptr_0): Remove.
(hook_uint_void_0): New.
* opts-common.c (decode_cmdline_option,
decode_cmdline_options_to_array): Also fill in canonical_option
field.
* opts.c (complain_wrong_lang): Use langhook to determine whether
to complain instead of special-casing LTO.
(decode_options): Separate lang_mask determination with
option_lang_mask hook from call of init_options hook.
* opts.h (struct cl_decoded_option): Add canonical_option.

ada:
* gcc-interface/misc.c (gnat_option_lang_mask): New.
(gnat_init_options): Update prototype.  Reconstruct argv array
from decoded options.

c-family:
* c-common.h (c_common_option_lang_mask,
c_common_initialize_diagnostics, c_common_complain_wrong_lang_p):
New.
(c_common_init_options): Update prototype.
* c-opts.c (c_common_option_lang_mask): New.
(c_common_initialize_diagnostics): Split out of
c_common_init_options.
(accept_all_c_family_options, c_common_complain_wrong_lang_p):
New.
(c_common_init_options): Update prototype.  Use decoded options in
search for -lang-asm.

cp:
* cp-objcp-common.c (cxx_initialize_diagnostics): First call
c_common_initialize_diagnostics.
* cp-objcp-common.h (LANG_HOOKS_OPTION_LANG_MASK,
LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define.

fortran:
* cpp.c (gfc_cpp_init_options): Update prototype.  Use number of
decoded options in allocating deferred_opt.
* cpp.h (gfc_cpp_init_options): Update prototype.
* f95-lang.c (LANG_HOOKS_OPTION_LANG_MASK): Define.
* gfortran.h (gfc_option_lang_mask): New.
(gfc_init_options): Update prototype.
* options.c (gfc_option_lang_mask): New.
(gfc_init_options): Update prototype.  Pass new arguments to
gfc_cpp_init_options.

java:
* lang.c (java_option_lang_mask): New.
(java_init_options): Update prototype.
(LANG_HOOKS_OPTION_LANG_MASK): Define.

lto:
* lto-lang.c (lto_option_lang_mask, lto_complain_wrong_lang_p):
New.
(lto_init_options): Update prototype.
(LANG_HOOKS_OPTION_LANG_MASK, LANG_HOOKS_COMPLAIN_WRONG_LANG_P):
Define.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162560 138bc75d-0d04-0410-961f-82ee72b054a4

30 files changed:
gcc/ChangeLog
gcc/ada/ChangeLog
gcc/ada/gcc-interface/misc.c
gcc/c-family/ChangeLog
gcc/c-family/c-common.h
gcc/c-family/c-opts.c
gcc/c-objc-common.c
gcc/c-objc-common.h
gcc/coretypes.h
gcc/cp/ChangeLog
gcc/cp/cp-objcp-common.c
gcc/cp/cp-objcp-common.h
gcc/fortran/ChangeLog
gcc/fortran/cpp.c
gcc/fortran/cpp.h
gcc/fortran/f95-lang.c
gcc/fortran/gfortran.h
gcc/fortran/options.c
gcc/hooks.c
gcc/hooks.h
gcc/java/ChangeLog
gcc/java/lang.c
gcc/langhooks-def.h
gcc/langhooks.c
gcc/langhooks.h
gcc/lto/ChangeLog
gcc/lto/lto-lang.c
gcc/opts-common.c
gcc/opts.c
gcc/opts.h

index f9a1b2f..62a2f18 100644 (file)
@@ -1,3 +1,31 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * langhooks-def.h (lhd_init_options, LANG_HOOKS_OPTION_LANG_MASK,
+       LANG_HOOKS_COMPLAIN_WRONG_LANG_P): New.
+       (LANG_HOOKS_INIT_OPTIONS): Update default definition.
+       (LANG_HOOKS_INITIALIZER): Add new hooks.
+       * langhooks.c (lhd_init_options, lhd_complain_wrong_lang_p): New.
+       * langhooks.h (struct lang_hooks): Add new hooks option_lang_mask
+       and complain_wrong_lang_p.  Update init_options prototype.
+       * c-objc-common.c (c_initialize_diagnostics): First call
+       c_common_initialize_diagnostics.
+       * c-objc-common.h (LANG_HOOKS_OPTION_LANG_MASK,
+       LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define.
+       * coretypes.h (struct cl_option, struct cl_decoded_option):
+       Declare.
+       * hooks.c (hook_uint_uint_constcharptrptr_0): Remove.
+       (hook_uint_void_0): New.
+       * hooks.h (hook_uint_uint_constcharptrptr_0): Remove.
+       (hook_uint_void_0): New.
+       * opts-common.c (decode_cmdline_option,
+       decode_cmdline_options_to_array): Also fill in canonical_option
+       field.
+       * opts.c (complain_wrong_lang): Use langhook to determine whether
+       to complain instead of special-casing LTO.
+       (decode_options): Separate lang_mask determination with
+       option_lang_mask hook from call of init_options hook.
+       * opts.h (struct cl_decoded_option): Add canonical_option.
+
 2010-07-27  Jakub Jelinek  <jakub@redhat.com>
 
        PR tree-optimization/45083
index 29618da..a8506db 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * gcc-interface/misc.c (gnat_option_lang_mask): New.
+       (gnat_init_options): Update prototype.  Reconstruct argv array
+       from decoded options.
+
 2010-07-23  Eric Botcazou  <ebotcazou@adacore.com>
 
        * gcc-interfaces/utils.c (update_pointer_to): In the unconstrained
index 8444e4f..43ed157 100644 (file)
@@ -61,7 +61,9 @@
 #include "gigi.h"
 
 static bool gnat_init                  (void);
-static unsigned int gnat_init_options  (unsigned int, const char **);
+static unsigned int gnat_option_lang_mask (void);
+static void gnat_init_options          (unsigned int,
+                                        struct cl_decoded_option *);
 static int gnat_handle_option          (size_t, const char *, int, int);
 static bool gnat_post_options          (const char **);
 static alias_set_type gnat_get_alias_set (tree);
@@ -85,6 +87,8 @@ static tree gnat_eh_personality               (void);
 #define LANG_HOOKS_IDENTIFIER_SIZE     sizeof (struct tree_identifier)
 #undef  LANG_HOOKS_INIT
 #define LANG_HOOKS_INIT                        gnat_init
+#undef  LANG_HOOKS_OPTION_LANG_MASK
+#define LANG_HOOKS_OPTION_LANG_MASK    gnat_option_lang_mask
 #undef  LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS                gnat_init_options
 #undef  LANG_HOOKS_HANDLE_OPTION
@@ -249,22 +253,43 @@ gnat_handle_option (size_t scode, const char *arg, int value,
   return 1;
 }
 
-/* Initialize for option processing.  */
+/* Return language mask for option processing.  */
 
 static unsigned int
-gnat_init_options (unsigned int argc, const char **argv)
+gnat_option_lang_mask (void)
 {
-  gnat_argv = (char **) xmalloc (sizeof (argv[0]));
-  gnat_argv[0] = xstrdup (argv[0]);     /* name of the command */
-  gnat_argc = 1;
+  return CL_Ada;
+}
+
+/* Initialize for option processing.  */
+
+static void
+gnat_init_options (unsigned int decoded_options_count,
+                  struct cl_decoded_option *decoded_options)
+{
+  /* Reconstruct an argv array for use of back_end.adb.
+
+     ??? back_end.adb should not rely on this; instead, it should work
+     with decoded options without such reparsing, to ensure
+     consistency in how options are decoded.  */
+  unsigned int i;
+
+  save_argv = XNEWVEC (const char *, 2 * decoded_options_count + 1);
+  save_argc = 0;
+  for (i = 0; i < decoded_options_count; i++)
+    {
+      save_argv[save_argc++] = decoded_options[i].canonical_option[0];
+      if (decoded_options[i].canonical_option[1] != NULL)
+       save_argv[save_argc++] = decoded_options[i].canonical_option[1];
+    }
+  save_argv[save_argc] = NULL;
 
-  save_argc = argc;
-  save_argv = argv;
+  gnat_argv = (char **) xmalloc (sizeof (save_argv[0]));
+  gnat_argv[0] = xstrdup (save_argv[0]);     /* name of the command */
+  gnat_argc = 1;
 
   /* Uninitialized really means uninitialized in Ada.  */
   flag_zero_initialized_in_bss = 0;
-
-  return CL_Ada;
 }
 
 /* Post-switch processing.  */
index b1d118f..7007582 100644 (file)
@@ -1,3 +1,17 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * c-common.h (c_common_option_lang_mask,
+       c_common_initialize_diagnostics, c_common_complain_wrong_lang_p):
+       New.
+       (c_common_init_options): Update prototype.
+       * c-opts.c (c_common_option_lang_mask): New.
+       (c_common_initialize_diagnostics): Split out of
+       c_common_init_options.
+       (accept_all_c_family_options, c_common_complain_wrong_lang_p):
+       New.
+       (c_common_init_options): Update prototype.  Use decoded options in
+       search for -lang-asm.
+
 2010-07-15  Nathan Froyd  <froydnj@codesourcery.com>
 
        * c-common.c: Carefully replace TREE_CHAIN with DECL_CHAIN.
index 78cf4fd..df9cf75 100644 (file)
@@ -1,6 +1,6 @@
 /* Definitions for c-common.c.
    Copyright (C) 1987, 1993, 1994, 1995, 1997, 1998,
-   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -724,7 +724,12 @@ extern void set_compound_literal_name (tree decl);
 
 extern tree build_va_arg (location_t, tree, tree);
 
-extern unsigned int c_common_init_options (unsigned int, const char **);
+struct diagnostic_context;
+
+extern unsigned int c_common_option_lang_mask (void);
+extern void c_common_initialize_diagnostics (struct diagnostic_context *);
+extern bool c_common_complain_wrong_lang_p (const struct cl_option *);
+extern void c_common_init_options (unsigned int, struct cl_decoded_option *);
 extern bool c_common_post_options (const char **);
 extern bool c_common_init (void);
 extern void c_common_finish (void);
index 2f8d5d8..ab22cf9 100644 (file)
@@ -281,14 +281,19 @@ warning_as_error_callback (int option_index)
     }
 }
 
-/* Common initialization before parsing options.  */
+/* Return language mask for option parsing.  */
 unsigned int
-c_common_init_options (unsigned int argc, const char **argv)
+c_common_option_lang_mask (void)
 {
   static const unsigned int lang_flags[] = {CL_C, CL_ObjC, CL_CXX, CL_ObjCXX};
-  unsigned int i, result;
-  struct cpp_callbacks *cb;
 
+  return lang_flags[c_language];
+}
+
+/* Common diagnostics initialization.  */
+void
+c_common_initialize_diagnostics (diagnostic_context *context)
+{
   /* Register callback for warnings enabled by -Werror=.  */
   register_warning_as_error_callback (warning_as_error_callback);
 
@@ -298,13 +303,37 @@ c_common_init_options (unsigned int argc, const char **argv)
     {
       /* By default wrap lines at 80 characters.  Is getenv
         ("COLUMNS") preferable?  */
-      diagnostic_line_cutoff (global_dc) = 80;
+      diagnostic_line_cutoff (context) = 80;
       /* By default, emit location information once for every
         diagnostic message.  */
-      diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
+      diagnostic_prefixing_rule (context) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
     }
 
-  global_dc->opt_permissive = OPT_fpermissive;
+  context->opt_permissive = OPT_fpermissive;
+}
+
+/* Whether options from all C-family languages should be accepted
+   quietly.  */
+static bool accept_all_c_family_options = false;
+
+/* Return whether to complain about a wrong-language option.  */
+bool
+c_common_complain_wrong_lang_p (const struct cl_option *option)
+{
+  if (accept_all_c_family_options
+      && (option->flags & c_family_lang_mask))
+    return false;
+
+  return true;
+}
+
+/* Common initialization before calling option handlers.  */
+void
+c_common_init_options (unsigned int decoded_options_count,
+                      struct cl_decoded_option *decoded_options)
+{
+  unsigned int i;
+  struct cpp_callbacks *cb;
 
   parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
                                ident_hash, line_table);
@@ -327,23 +356,19 @@ c_common_init_options (unsigned int argc, const char **argv)
   /* By default, C99-like requirements for complex multiply and divide.  */
   flag_complex_method = 2;
 
-  deferred_opts = XNEWVEC (struct deferred_opt, argc);
-
-  result = lang_flags[c_language];
+  deferred_opts = XNEWVEC (struct deferred_opt, decoded_options_count);
 
   if (c_language == clk_c)
     {
       /* If preprocessing assembly language, accept any of the C-family
         front end options since the driver may pass them through.  */
-      for (i = 1; i < argc; i++)
-       if (! strcmp (argv[i], "-lang-asm"))
+      for (i = 1; i < decoded_options_count; i++)
+       if (decoded_options[i].opt_index == OPT_lang_asm)
          {
-           result |= CL_C | CL_ObjC | CL_CXX | CL_ObjCXX;
+           accept_all_c_family_options = true;
            break;
          }
     }
-
-  return result;
 }
 
 /* Handle switch SCODE with argument ARG.  VALUE is true, unless no-
index d1cac99..9351cd5 100644 (file)
@@ -184,8 +184,13 @@ has_c_linkage (const_tree decl ATTRIBUTE_UNUSED)
 void
 c_initialize_diagnostics (diagnostic_context *context)
 {
-  pretty_printer *base = context->printer;
-  c_pretty_printer *pp = XNEW (c_pretty_printer);
+  pretty_printer *base;
+  c_pretty_printer *pp;
+
+  c_common_initialize_diagnostics (context);
+
+  base = context->printer;
+  pp = XNEW (c_pretty_printer);
   memcpy (pp_base (pp), base, sizeof (pretty_printer));
   pp_c_pretty_printer_init (pp);
   context->printer = (pretty_printer *) pp;
index 8408b9f..c2b5ffa 100644 (file)
@@ -1,5 +1,6 @@
 /* Language hooks common to C and ObjC front ends.
-   Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Ziemowit Laski  <zlaski@apple.com>
 
 This file is part of GCC.
@@ -28,6 +29,10 @@ along with GCC; see the file COPYING3.  If not see
 #define LANG_HOOKS_IDENTIFIER_SIZE C_SIZEOF_STRUCT_LANG_IDENTIFIER
 #undef LANG_HOOKS_FINISH
 #define LANG_HOOKS_FINISH c_common_finish
+#undef LANG_HOOKS_OPTION_LANG_MASK
+#define LANG_HOOKS_OPTION_LANG_MASK c_common_option_lang_mask
+#undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
+#define LANG_HOOKS_COMPLAIN_WRONG_LANG_P c_common_complain_wrong_lang_p
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_INITIALIZE_DIAGNOSTICS
index b631d94..25539c3 100644 (file)
@@ -1,5 +1,6 @@
 /* GCC core type declarations.
-   Copyright (C) 2002, 2004, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -65,6 +66,8 @@ union section;
 typedef union section section;
 struct cl_target_option;
 struct cl_optimization;
+struct cl_option;
+struct cl_decoded_option;
 struct gimple_seq_d;
 typedef struct gimple_seq_d *gimple_seq;
 typedef const struct gimple_seq_d *const_gimple_seq;
index b7b08bb..7829c5b 100644 (file)
@@ -1,3 +1,10 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * cp-objcp-common.c (cxx_initialize_diagnostics): First call
+       c_common_initialize_diagnostics.
+       * cp-objcp-common.h (LANG_HOOKS_OPTION_LANG_MASK,
+       LANG_HOOKS_COMPLAIN_WRONG_LANG_P): Define.
+
 2010-07-21  Jason Merrill  <jason@redhat.com>
 
        * tree.c (cp_tree_equal): Fix CONSTRUCTOR handling.
index 9cfe770..0fdb87a 100644 (file)
@@ -129,8 +129,13 @@ cp_var_mod_type_p (tree type, tree fn)
 void
 cxx_initialize_diagnostics (diagnostic_context *context)
 {
-  pretty_printer *base = context->printer;
-  cxx_pretty_printer *pp = XNEW (cxx_pretty_printer);
+  pretty_printer *base;
+  cxx_pretty_printer *pp;
+
+  c_common_initialize_diagnostics (context);
+
+  base = context->printer;
+  pp = XNEW (cxx_pretty_printer);
   memcpy (pp_base (pp), base, sizeof (pretty_printer));
   pp_cxx_pretty_printer_init (pp);
   context->printer = (pretty_printer *) pp;
index f2d4aa1..5e26b33 100644 (file)
@@ -1,5 +1,6 @@
 /* Language hooks common to C++ and ObjC++ front ends.
-   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+   Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010
+   Free Software Foundation, Inc.
    Contributed by Ziemowit Laski  <zlaski@apple.com>
 
 This file is part of GCC.
@@ -40,6 +41,10 @@ extern bool cp_function_decl_explicit_p (tree decl);
 #define LANG_HOOKS_FINISH cxx_finish
 #undef LANG_HOOKS_CLEAR_BINDING_STACK
 #define LANG_HOOKS_CLEAR_BINDING_STACK pop_everything
+#undef LANG_HOOKS_OPTION_LANG_MASK
+#define LANG_HOOKS_OPTION_LANG_MASK c_common_option_lang_mask
+#undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
+#define LANG_HOOKS_COMPLAIN_WRONG_LANG_P c_common_complain_wrong_lang_p
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS c_common_init_options
 #undef LANG_HOOKS_INITIALIZE_DIAGNOSTICS
index 7700e0b..dcff2b2 100644 (file)
@@ -1,3 +1,15 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * cpp.c (gfc_cpp_init_options): Update prototype.  Use number of
+       decoded options in allocating deferred_opt.
+       * cpp.h (gfc_cpp_init_options): Update prototype.
+       * f95-lang.c (LANG_HOOKS_OPTION_LANG_MASK): Define.
+       * gfortran.h (gfc_option_lang_mask): New.
+       (gfc_init_options): Update prototype.
+       * options.c (gfc_option_lang_mask): New.
+       (gfc_init_options): Update prototype.  Pass new arguments to
+       gfc_cpp_init_options.
+
 2010-07-26  Tobias Burnus  <burnus@net-b.de>
 
        PR fortran/40873
index 7f960f5..b98d83f 100644 (file)
@@ -304,8 +304,8 @@ gfc_cpp_temporary_file (void)
 }
 
 void
-gfc_cpp_init_options (unsigned int argc,
-                     const char **argv ATTRIBUTE_UNUSED)
+gfc_cpp_init_options (unsigned int decoded_options_count,
+                     struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
 {
   /* Do not create any objects from libcpp here. If no
      preprocessing is requested, this would be wasted
@@ -337,7 +337,8 @@ gfc_cpp_init_options (unsigned int argc,
   gfc_cpp_option.prefix = NULL;
   gfc_cpp_option.sysroot = NULL;
 
-  gfc_cpp_option.deferred_opt = XNEWVEC (gfc_cpp_deferred_opt_t, argc);
+  gfc_cpp_option.deferred_opt = XNEWVEC (gfc_cpp_deferred_opt_t,
+                                        decoded_options_count);
   gfc_cpp_option.deferred_opt_count = 0;
 }
 
index 556eecb..fa4383a 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2008, 2010 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -36,7 +36,8 @@ const char *gfc_cpp_temporary_file (void);
 void gfc_cpp_init_0 (void);
 void gfc_cpp_init (void);
 
-void gfc_cpp_init_options (unsigned int argc, const char **argv);
+void gfc_cpp_init_options (unsigned int decoded_options_count,
+                          struct cl_decoded_option *decoded_options);
 
 int gfc_cpp_handle_option(size_t scode, const char *arg, int value);
 
index 9d0bf44..70548bf 100644 (file)
@@ -101,6 +101,7 @@ static void gfc_init_ts (void);
 #undef LANG_HOOKS_INIT
 #undef LANG_HOOKS_FINISH
 #undef LANG_HOOKS_WRITE_GLOBALS
+#undef LANG_HOOKS_OPTION_LANG_MASK
 #undef LANG_HOOKS_INIT_OPTIONS
 #undef LANG_HOOKS_HANDLE_OPTION
 #undef LANG_HOOKS_POST_OPTIONS
@@ -130,6 +131,7 @@ static void gfc_init_ts (void);
 #define LANG_HOOKS_INIT                 gfc_init
 #define LANG_HOOKS_FINISH               gfc_finish
 #define LANG_HOOKS_WRITE_GLOBALS       gfc_write_global_declarations
+#define LANG_HOOKS_OPTION_LANG_MASK    gfc_option_lang_mask
 #define LANG_HOOKS_INIT_OPTIONS         gfc_init_options
 #define LANG_HOOKS_HANDLE_OPTION        gfc_handle_option
 #define LANG_HOOKS_POST_OPTIONS                gfc_post_options
index bb056e2..f082d5e 100644 (file)
@@ -2355,7 +2355,9 @@ void gfc_done_2 (void);
 int get_c_kind (const char *, CInteropKind_t *);
 
 /* options.c */
-unsigned int gfc_init_options (unsigned int, const char **);
+unsigned int gfc_option_lang_mask (void);
+void gfc_init_options (unsigned int,
+                      struct cl_decoded_option *);
 int gfc_handle_option (size_t, const char *, int, int);
 bool gfc_post_options (const char **);
 
index 5ba2544..337802e 100644 (file)
@@ -53,11 +53,21 @@ set_default_std_flags (void)
 }
 
 
+/* Return language mask for Fortran options.  */
+
+unsigned int
+gfc_option_lang_mask (void)
+{
+  return CL_Fortran;
+}
+
+
 /* Get ready for options handling. Keep in sync with
    libgfortran/runtime/compile_options.c (init_compile_options). */
 
-unsigned int
-gfc_init_options (unsigned int argc, const char **argv)
+void
+gfc_init_options (unsigned int decoded_options_count,
+                 struct cl_decoded_option *decoded_options)
 {
   gfc_source_file = NULL;
   gfc_option.module_dir = NULL;
@@ -143,9 +153,7 @@ gfc_init_options (unsigned int argc, const char **argv)
   flag_short_enums = targetm.default_short_enums ();
 
   /* Initialize cpp-related options.  */
-  gfc_cpp_init_options(argc, argv);
-
-  return CL_Fortran;
+  gfc_cpp_init_options (decoded_options_count, decoded_options);
 }
 
 
index 97e1064..355509a 100644 (file)
@@ -1,5 +1,5 @@
 /* General-purpose hooks.
-   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
@@ -176,8 +176,7 @@ hook_int_size_t_constcharptr_int_0 (size_t a ATTRIBUTE_UNUSED,
 }
 
 unsigned int
-hook_uint_uint_constcharptrptr_0 (unsigned int a ATTRIBUTE_UNUSED,
-                                 const char **b ATTRIBUTE_UNUSED)
+hook_uint_void_0 (void)
 {
   return 0;
 }
index 5028062..db1da30 100644 (file)
@@ -1,5 +1,5 @@
 /* General-purpose hooks.
-   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009
+   Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify it
@@ -73,7 +73,7 @@ extern tree hook_tree_tree_tree_tree_null (tree, tree, tree);
 extern tree hook_tree_tree_tree_tree_3rd_identity (tree, tree, tree);
 extern tree hook_tree_tree_int_treep_bool_null (tree, int, tree *, bool);
 
-extern unsigned hook_uint_uint_constcharptrptr_0 (unsigned, const char **);
+extern unsigned hook_uint_void_0 (void);
 
 extern bool default_can_output_mi_thunk_no_vcall (const_tree, HOST_WIDE_INT,
                                                  HOST_WIDE_INT, const_tree);
index 372739f..47c5e0f 100644 (file)
@@ -1,3 +1,9 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * lang.c (java_option_lang_mask): New.
+       (java_init_options): Update prototype.
+       (LANG_HOOKS_OPTION_LANG_MASK): Define.
+
 2010-07-15  Nathan Froyd  <froydnj@codesourcery.com>
 
        * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN.
index 6c31947..c084cb8 100644 (file)
@@ -46,7 +46,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc.  */
 
 static bool java_init (void);
 static void java_finish (void);
-static unsigned int java_init_options (unsigned int, const char **);
+static unsigned int java_option_lang_mask (void);
+static void java_init_options (unsigned int, struct cl_decoded_option *);
 static bool java_post_options (const char **);
 
 static int java_handle_option (size_t scode, const char *arg, int value, int kind);
@@ -121,6 +122,8 @@ struct GTY(()) language_function {
 #define LANG_HOOKS_INIT java_init
 #undef LANG_HOOKS_FINISH
 #define LANG_HOOKS_FINISH java_finish
+#undef LANG_HOOKS_OPTION_LANG_MASK
+#define LANG_HOOKS_OPTION_LANG_MASK java_option_lang_mask
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS java_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
@@ -525,8 +528,14 @@ lang_init_source (int level)
 }
 
 static unsigned int
-java_init_options (unsigned int argc ATTRIBUTE_UNUSED,
-                  const char **argv ATTRIBUTE_UNUSED)
+java_option_lang_mask (void)
+{
+  return CL_Java;
+}
+
+static void
+java_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
+                  struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
 {
   flag_bounds_check = 1;
   flag_exceptions = 1;
@@ -542,8 +551,6 @@ java_init_options (unsigned int argc ATTRIBUTE_UNUSED,
   flag_evaluation_order = 1;
 
   jcf_path_init ();
-
-  return CL_Java;
 }
 
 /* Post-switch processing.  */
index 68085c7..504fdad 100644 (file)
@@ -1,5 +1,5 @@
 /* Default macros to initialize the lang_hooks data structure.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Alexandre Oliva  <aoliva@redhat.com>
 
@@ -66,6 +66,9 @@ extern tree lhd_builtin_function (tree);
 
 /* Declarations of default tree inlining hooks.  */
 extern void lhd_initialize_diagnostics (struct diagnostic_context *);
+extern void lhd_init_options (unsigned int,
+                             struct cl_decoded_option *);
+extern bool lhd_complain_wrong_lang_p (const struct cl_option *);
 extern tree lhd_callgraph_analyze_expr (tree *, int *);
 
 
@@ -82,8 +85,10 @@ extern void lhd_omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *,
 #define LANG_HOOKS_INIT                        hook_bool_void_false
 #define LANG_HOOKS_FINISH              lhd_do_nothing
 #define LANG_HOOKS_PARSE_FILE          lhd_do_nothing_i
-#define LANG_HOOKS_INIT_OPTIONS                hook_uint_uint_constcharptrptr_0
+#define LANG_HOOKS_OPTION_LANG_MASK    hook_uint_void_0
+#define LANG_HOOKS_INIT_OPTIONS                lhd_init_options
 #define LANG_HOOKS_INITIALIZE_DIAGNOSTICS lhd_initialize_diagnostics
+#define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lhd_complain_wrong_lang_p
 #define LANG_HOOKS_HANDLE_OPTION       hook_int_size_t_constcharptr_int_0
 #define LANG_HOOKS_MISSING_ARGUMENT    hook_bool_constcharptr_size_t_false
 #define LANG_HOOKS_POST_OPTIONS                lhd_post_options
@@ -258,8 +263,10 @@ extern void lhd_end_section (void);
   LANG_HOOKS_IDENTIFIER_SIZE, \
   LANG_HOOKS_FREE_LANG_DATA, \
   LANG_HOOKS_TREE_SIZE, \
+  LANG_HOOKS_OPTION_LANG_MASK, \
   LANG_HOOKS_INIT_OPTIONS, \
   LANG_HOOKS_INITIALIZE_DIAGNOSTICS, \
+  LANG_HOOKS_COMPLAIN_WRONG_LANG_P, \
   LANG_HOOKS_HANDLE_OPTION, \
   LANG_HOOKS_MISSING_ARGUMENT, \
   LANG_HOOKS_POST_OPTIONS, \
index f56b42b..1becd55 100644 (file)
@@ -337,6 +337,20 @@ lhd_initialize_diagnostics (struct diagnostic_context *ctx ATTRIBUTE_UNUSED)
 {
 }
 
+/* Called to perform language-specific options initialization.  */
+void
+lhd_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
+                 struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
+{
+}
+
+/* By default, always complain about options for the wrong language.  */
+bool
+lhd_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
+{
+  return true;
+}
+
 /* The default function to print out name of current function that caused
    an error.  */
 void
index 483a8dc..4702d14 100644 (file)
@@ -1,5 +1,5 @@
 /* The lang_hooks data structure.
-   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+   Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -269,15 +269,24 @@ struct lang_hooks
      on unrecognized codes.  */
   size_t (*tree_size) (enum tree_code);
 
-  /* The first callback made to the front end, for simple
-     initialization needed before any calls to handle_option.  Return
-     the language mask to filter the switch array with.  */
-  unsigned int (*init_options) (unsigned int argc, const char **argv);
+  /* Return the language mask used for converting argv into a sequence
+     of options.  */
+  unsigned int (*option_lang_mask) (void);
+
+  /* After the initialize_diagnostics hook is called, do any simple
+     initialization needed before any calls to handle_option.  */
+  void (*init_options) (unsigned int decoded_options_count,
+                       struct cl_decoded_option *decoded_options);
 
   /* Callback used to perform language-specific initialization for the
      global diagnostic context structure.  */
   void (*initialize_diagnostics) (struct diagnostic_context *);
 
+  /* Return true if a warning should be given about option OPTION,
+     which is for the wrong language, false if it should be quietly
+     ignored.  */
+  bool (*complain_wrong_lang_p) (const struct cl_option *option);
+
   /* 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 responsible for
index 6d3e7b8..28b5949 100644 (file)
@@ -1,3 +1,11 @@
+2010-07-27  Joseph Myers  <joseph@codesourcery.com>
+
+       * lto-lang.c (lto_option_lang_mask, lto_complain_wrong_lang_p):
+       New.
+       (lto_init_options): Update prototype.
+       (LANG_HOOKS_OPTION_LANG_MASK, LANG_HOOKS_COMPLAIN_WRONG_LANG_P):
+       Define.
+
 2010-07-10   Andi Kleen <ak@linux.intel.com>
 
        PR lto/44992
index fc25df6..0915ac0 100644 (file)
@@ -595,16 +595,34 @@ static GTY(()) tree registered_builtin_fndecls;
 /* Language hooks.  */
 
 static unsigned int
-lto_init_options (unsigned int argc ATTRIBUTE_UNUSED,
-                 const char **argv ATTRIBUTE_UNUSED)
+lto_option_lang_mask (void)
+{
+  return CL_LTO;
+}
+
+static bool
+lto_complain_wrong_lang_p (const struct cl_option *option ATTRIBUTE_UNUSED)
+{
+  /* The LTO front end inherits all the options from the first front
+     end that was used.  However, not all the original front end
+     options make sense in LTO.
+
+     A real solution would be to filter this in collect2, but collect2
+     does not have access to all the option attributes to know what to
+     filter.  So, in lto1 we silently accept inherited flags and do
+     nothing about it.  */
+  return false;
+}
+
+static void
+lto_init_options (unsigned int decoded_options_count ATTRIBUTE_UNUSED,
+                 struct cl_decoded_option *decoded_options ATTRIBUTE_UNUSED)
 {
   /* By default, C99-like requirements for complex multiply and divide.
      ???  Until the complex method is encoded in the IL this is the only
      safe choice.  This will pessimize Fortran code with LTO unless
      people specify a complex method manually or use -ffast-math.  */
   flag_complex_method = 2;
-
-  return CL_LTO;
 }
 
 /* Handle command-line option SCODE.  If the option takes an argument, it is
@@ -1116,6 +1134,10 @@ static void lto_init_ts (void)
 
 #undef LANG_HOOKS_NAME
 #define LANG_HOOKS_NAME "GNU GIMPLE"
+#undef LANG_HOOKS_OPTION_LANG_MASK
+#define LANG_HOOKS_OPTION_LANG_MASK lto_option_lang_mask
+#undef LANG_HOOKS_COMPLAIN_WRONG_LANG_P
+#define LANG_HOOKS_COMPLAIN_WRONG_LANG_P lto_complain_wrong_lang_p
 #undef LANG_HOOKS_INIT_OPTIONS
 #define LANG_HOOKS_INIT_OPTIONS lto_init_options
 #undef LANG_HOOKS_HANDLE_OPTION
index cde8ccf..6b24b37 100644 (file)
@@ -245,10 +245,14 @@ decode_cmdline_option (const char **argv, unsigned int lang_mask,
     {
     case 1:
       decoded->orig_option_with_args_text = argv[0];
+      decoded->canonical_option[0] = argv[0];
+      decoded->canonical_option[1] = NULL;
       break;
     case 2:
       decoded->orig_option_with_args_text = concat (argv[0], " ",
                                                    argv[1], NULL);
+      decoded->canonical_option[0] = argv[0];
+      decoded->canonical_option[1] = argv[1];
       break;
     default:
       gcc_unreachable ();
@@ -279,6 +283,8 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv,
   opt_array[0].opt_index = OPT_SPECIAL_program_name;
   opt_array[0].arg = argv[0];
   opt_array[0].orig_option_with_args_text = argv[0];
+  opt_array[0].canonical_option[0] = argv[0];
+  opt_array[0].canonical_option[1] = NULL;
   opt_array[0].value = 1;
   opt_array[0].errors = 0;
   num_decoded_options = 1;
@@ -293,6 +299,8 @@ decode_cmdline_options_to_array (unsigned int argc, const char **argv,
          opt_array[num_decoded_options].opt_index = OPT_SPECIAL_input_file;
          opt_array[num_decoded_options].arg = opt;
          opt_array[num_decoded_options].orig_option_with_args_text = opt;
+         opt_array[num_decoded_options].canonical_option[0] = opt;
+         opt_array[num_decoded_options].canonical_option[1] = NULL;
          opt_array[num_decoded_options].value = 1;
          opt_array[num_decoded_options].errors = 0;
          num_decoded_options++;
index 07d7a23..2016ed4 100644 (file)
@@ -416,15 +416,7 @@ complain_wrong_lang (const char *text, const struct cl_option *option,
 {
   char *ok_langs, *bad_lang;
 
-  /* The LTO front end inherits all the options from the first front
-     end that was used.  However, not all the original front end
-     options make sense in LTO.
-
-     A real solution would be to filter this in collect2, but collect2
-     does not have access to all the option attributes to know what to
-     filter.  So, in lto1 we silently accept inherited flags and do
-     nothing about it.  */
-  if (lang_mask & CL_LTO)
+  if (!lang_hooks.complain_wrong_lang_p (option))
     return;
 
   ok_langs = write_langs (option->flags);
@@ -715,7 +707,7 @@ decode_options (unsigned int argc, const char **argv,
   if (first_time_p)
     {
       /* Perform language-specific options initialization.  */
-      initial_lang_mask = lang_mask = lang_hooks.init_options (argc, argv);
+      initial_lang_mask = lang_mask = lang_hooks.option_lang_mask ();
 
       lang_hooks.initialize_diagnostics (global_dc);
 
@@ -732,6 +724,9 @@ decode_options (unsigned int argc, const char **argv,
 
   decode_cmdline_options_to_array (argc, argv, lang_mask,
                                   decoded_options, decoded_options_count);
+  if (first_time_p)
+    /* Perform language-specific options initialization.  */
+    lang_hooks.init_options (*decoded_options_count, *decoded_options);
 
   /* Scan to see what optimization level has been specified.  That will
      determine the default value of many flags.  */
index 554bb23..fbc86b1 100644 (file)
@@ -117,6 +117,14 @@ struct cl_decoded_option
      -frecord-gcc-switches.  */
   const char *orig_option_with_args_text;
 
+  /* The canonical form of the option and its argument, for when it is
+     necessary to reconstruct argv elements (in particular, for
+     processing specs and passing options to subprocesses from the
+     driver).  The first element of this array is non-NULL; the second
+     is NULL if the canonical form uses only one argv element,
+     non-NULL otherwise.  */
+  const char *canonical_option[2];
+
   /* For a boolean option, 1 for the true case and 0 for the "no-"
      case.  For an unsigned integer option, the value of the
      argument.  1 in all other cases.  */