diff options
author | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-27 09:59:51 +0000 |
---|---|---|
committer | jsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-07-27 09:59:51 +0000 |
commit | e88d34f666c45d3a0f1f446641bb34b2b5ea1e13 (patch) | |
tree | cb22bfd268b7388c3f8e1f2942cb855aada62993 | |
parent | 2e4223e32376364572cb2aff91065c627a79d8ba (diff) | |
download | gcc-e88d34f666c45d3a0f1f446641bb34b2b5ea1e13.tar.gz |
* 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.
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
-rw-r--r-- | gcc/ChangeLog | 28 | ||||
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/misc.c | 45 | ||||
-rw-r--r-- | gcc/c-family/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/c-family/c-common.h | 9 | ||||
-rw-r--r-- | gcc/c-family/c-opts.c | 55 | ||||
-rw-r--r-- | gcc/c-objc-common.c | 9 | ||||
-rw-r--r-- | gcc/c-objc-common.h | 7 | ||||
-rw-r--r-- | gcc/coretypes.h | 5 | ||||
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.c | 9 | ||||
-rw-r--r-- | gcc/cp/cp-objcp-common.h | 7 | ||||
-rw-r--r-- | gcc/fortran/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/fortran/cpp.c | 7 | ||||
-rw-r--r-- | gcc/fortran/cpp.h | 5 | ||||
-rw-r--r-- | gcc/fortran/f95-lang.c | 2 | ||||
-rw-r--r-- | gcc/fortran/gfortran.h | 4 | ||||
-rw-r--r-- | gcc/fortran/options.c | 18 | ||||
-rw-r--r-- | gcc/hooks.c | 5 | ||||
-rw-r--r-- | gcc/hooks.h | 4 | ||||
-rw-r--r-- | gcc/java/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/java/lang.c | 17 | ||||
-rw-r--r-- | gcc/langhooks-def.h | 11 | ||||
-rw-r--r-- | gcc/langhooks.c | 14 | ||||
-rw-r--r-- | gcc/langhooks.h | 19 | ||||
-rw-r--r-- | gcc/lto/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/lto/lto-lang.c | 30 | ||||
-rw-r--r-- | gcc/opts-common.c | 8 | ||||
-rw-r--r-- | gcc/opts.c | 15 | ||||
-rw-r--r-- | gcc/opts.h | 8 |
30 files changed, 318 insertions, 76 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f9a1b2f53f3..62a2f184c2d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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 diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 29618da8ecd..a8506db93ed 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -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 diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 8444e4f714c..43ed1571f4a 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -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. */ diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog index b1d118fe6a1..7007582bb9d 100644 --- a/gcc/c-family/ChangeLog +++ b/gcc/c-family/ChangeLog @@ -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. diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h index 78cf4fdb2b5..df9cf759a5a 100644 --- a/gcc/c-family/c-common.h +++ b/gcc/c-family/c-common.h @@ -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); diff --git a/gcc/c-family/c-opts.c b/gcc/c-family/c-opts.c index 2f8d5d86230..ab22cf993b8 100644 --- a/gcc/c-family/c-opts.c +++ b/gcc/c-family/c-opts.c @@ -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- diff --git a/gcc/c-objc-common.c b/gcc/c-objc-common.c index d1cac99d562..9351cd5a539 100644 --- a/gcc/c-objc-common.c +++ b/gcc/c-objc-common.c @@ -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; diff --git a/gcc/c-objc-common.h b/gcc/c-objc-common.h index 8408b9ffdfe..c2b5ffab86a 100644 --- a/gcc/c-objc-common.h +++ b/gcc/c-objc-common.h @@ -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 diff --git a/gcc/coretypes.h b/gcc/coretypes.h index b631d94d85f..25539c3d543 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -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; diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b7b08bbb526..7829c5b9a7b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/cp-objcp-common.c b/gcc/cp/cp-objcp-common.c index 9cfe7702aca..0fdb87a4cc4 100644 --- a/gcc/cp/cp-objcp-common.c +++ b/gcc/cp/cp-objcp-common.c @@ -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; diff --git a/gcc/cp/cp-objcp-common.h b/gcc/cp/cp-objcp-common.h index f2d4aa1cceb..5e26b335ca5 100644 --- a/gcc/cp/cp-objcp-common.h +++ b/gcc/cp/cp-objcp-common.h @@ -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 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 7700e0bc7d1..dcff2b2f4e1 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -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 diff --git a/gcc/fortran/cpp.c b/gcc/fortran/cpp.c index 7f960f5e557..b98d83f1b48 100644 --- a/gcc/fortran/cpp.c +++ b/gcc/fortran/cpp.c @@ -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; } diff --git a/gcc/fortran/cpp.h b/gcc/fortran/cpp.h index 556eecbc099..fa4383aefeb 100644 --- a/gcc/fortran/cpp.h +++ b/gcc/fortran/cpp.h @@ -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); diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 9d0bf446bab..70548bf2b25 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -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 diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index bb056e2e531..f082d5e5974 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -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 **); diff --git a/gcc/fortran/options.c b/gcc/fortran/options.c index 5ba2544392a..337802e35a7 100644 --- a/gcc/fortran/options.c +++ b/gcc/fortran/options.c @@ -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); } diff --git a/gcc/hooks.c b/gcc/hooks.c index 97e10646088..355509ad7b9 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -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; } diff --git a/gcc/hooks.h b/gcc/hooks.h index 50280628ab8..db1da30398d 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -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); diff --git a/gcc/java/ChangeLog b/gcc/java/ChangeLog index 372739ff5a7..47c5e0f1332 100644 --- a/gcc/java/ChangeLog +++ b/gcc/java/ChangeLog @@ -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. diff --git a/gcc/java/lang.c b/gcc/java/lang.c index 6c31947c6a4..c084cb88a7c 100644 --- a/gcc/java/lang.c +++ b/gcc/java/lang.c @@ -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. */ diff --git a/gcc/langhooks-def.h b/gcc/langhooks-def.h index 68085c72c9e..504fdad5920 100644 --- a/gcc/langhooks-def.h +++ b/gcc/langhooks-def.h @@ -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, \ diff --git a/gcc/langhooks.c b/gcc/langhooks.c index f56b42b7786..1becd557c8a 100644 --- a/gcc/langhooks.c +++ b/gcc/langhooks.c @@ -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 diff --git a/gcc/langhooks.h b/gcc/langhooks.h index 483a8dcdd77..4702d143daa 100644 --- a/gcc/langhooks.h +++ b/gcc/langhooks.h @@ -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 diff --git a/gcc/lto/ChangeLog b/gcc/lto/ChangeLog index 6d3e7b8bc7f..28b594977e4 100644 --- a/gcc/lto/ChangeLog +++ b/gcc/lto/ChangeLog @@ -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 diff --git a/gcc/lto/lto-lang.c b/gcc/lto/lto-lang.c index fc25df6b9e5..0915ac0ad40 100644 --- a/gcc/lto/lto-lang.c +++ b/gcc/lto/lto-lang.c @@ -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 diff --git a/gcc/opts-common.c b/gcc/opts-common.c index cde8ccfe29b..6b24b37ce5d 100644 --- a/gcc/opts-common.c +++ b/gcc/opts-common.c @@ -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++; diff --git a/gcc/opts.c b/gcc/opts.c index 07d7a23ae38..2016ed4d441 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -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. */ diff --git a/gcc/opts.h b/gcc/opts.h index 554bb235b3d..fbc86b1c36e 100644 --- a/gcc/opts.h +++ b/gcc/opts.h @@ -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. */ |