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
+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
+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
#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);
#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
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. */
+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.
/* 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.
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);
}
}
-/* 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);
{
/* 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);
/* 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-
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;
/* 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.
#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
/* 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.
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;
+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.
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;
/* 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.
#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
+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
}
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
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;
}
-/* Copyright (C) 2008 Free Software Foundation, Inc.
+/* Copyright (C) 2008, 2010 Free Software Foundation, Inc.
This file is part of GCC.
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);
#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
#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
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 **);
}
+/* 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;
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);
}
/* 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
}
unsigned int
-hook_uint_uint_constcharptrptr_0 (unsigned int a ATTRIBUTE_UNUSED,
- const char **b ATTRIBUTE_UNUSED)
+hook_uint_void_0 (void)
{
return 0;
}
/* 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
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);
+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.
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);
#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
}
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;
flag_evaluation_order = 1;
jcf_path_init ();
-
- return CL_Java;
}
/* Post-switch processing. */
/* 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>
/* 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 *);
#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
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, \
{
}
+/* 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
/* 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.
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
+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
/* 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
#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
{
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 ();
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;
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++;
{
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);
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);
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. */
-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. */