opts-common.c (handle_option, [...]): Add diagnostic_context parameter.

* opts-common.c (handle_option, handle_generated_option,
	read_cmdline_option, set_option): Add diagnostic_context
	parameter.  Update calls among these functions.
	(set_option): Don't use global_dc.
	* opts.c (read_cmdline_options): Pass global_dc to
	read_cmdline_option.
	(decode_options): Pass global_dc to enable_warning_as_error.
	(common_handle_option): Pass global_dc to enable_warning_as_error.
	(enable_warning_as_error): Add diagnostic_context parameter.
	Document parameters.  Don't use global_dc.  Pass
	diagnostic_context parameter to handle_generated_option.
	* opts.h (set_option, handle_option, handle_generated_option,
	read_cmdline_option, enable_warning_as_error): Add
	diagnostic_context parameter.
	* Makefile.in (lto-opts.o): Update dependencies.
	* coretypes.h (struct diagnostic_context, diagnostic_context):
	Declare here.
	* diagnostic.h (diagnostic_context): Don't declare typedef here.
	* gcc.c (process_command): Pass global_dc to read_cmdline_option.
	* langhooks-def.h (struct diagnostic_context): Don't declare here.
	(lhd_print_error_function, lhd_initialize_diagnostics): Declare
	using diagnostic_context typedef.
	* langhooks.c (lhd_initialize_diagnostics): Declare using
	diagnostic_context typedef.
	* langhooks.h (struct diagnostic_context): Don't declare here.
	(initialize_diagnostics, print_error_function): Declare using
	diagnostic_context typedef.
	* lto-opts.c: Include diagnostic.h.
	(lto_reissue_options): Pass global_dc to set_option.  Pass
	DK_UNSPECIFIED not 0.
	* plugin.c (plugins_internal_error_function): Declare using
	diagnostic_context typedef.
	* plugin.h (struct diagnostic_context): Don't declare here.
	(plugins_internal_error_function): Declare using
	diagnostic_context typedef.

c-family:
	* c-common.h (struct diagnostic_context): Don't declare here.
	(c_common_initialize_diagnostics): Declare using
	diagnostic_context typedef.
	* c-opts.c (c_common_handle_option): Pass global_dc to
	handle_generated_option.

cp:
	* cp-tree.h (cxx_print_error_function,
	cxx_initialize_diagnostics): Declare using diagnostic_context
	typedef.

From-SVN: r164991
This commit is contained in:
Joseph Myers 2010-10-05 15:28:39 +01:00 committed by Joseph Myers
parent bcee41ff81
commit 1ebe4b4fa0
19 changed files with 119 additions and 49 deletions

View File

@ -1,3 +1,41 @@
2010-10-05 Joseph Myers <joseph@codesourcery.com>
* opts-common.c (handle_option, handle_generated_option,
read_cmdline_option, set_option): Add diagnostic_context
parameter. Update calls among these functions.
(set_option): Don't use global_dc.
* opts.c (read_cmdline_options): Pass global_dc to
read_cmdline_option.
(decode_options): Pass global_dc to enable_warning_as_error.
(common_handle_option): Pass global_dc to enable_warning_as_error.
(enable_warning_as_error): Add diagnostic_context parameter.
Document parameters. Don't use global_dc. Pass
diagnostic_context parameter to handle_generated_option.
* opts.h (set_option, handle_option, handle_generated_option,
read_cmdline_option, enable_warning_as_error): Add
diagnostic_context parameter.
* Makefile.in (lto-opts.o): Update dependencies.
* coretypes.h (struct diagnostic_context, diagnostic_context):
Declare here.
* diagnostic.h (diagnostic_context): Don't declare typedef here.
* gcc.c (process_command): Pass global_dc to read_cmdline_option.
* langhooks-def.h (struct diagnostic_context): Don't declare here.
(lhd_print_error_function, lhd_initialize_diagnostics): Declare
using diagnostic_context typedef.
* langhooks.c (lhd_initialize_diagnostics): Declare using
diagnostic_context typedef.
* langhooks.h (struct diagnostic_context): Don't declare here.
(initialize_diagnostics, print_error_function): Declare using
diagnostic_context typedef.
* lto-opts.c: Include diagnostic.h.
(lto_reissue_options): Pass global_dc to set_option. Pass
DK_UNSPECIFIED not 0.
* plugin.c (plugins_internal_error_function): Declare using
diagnostic_context typedef.
* plugin.h (struct diagnostic_context): Don't declare here.
(plugins_internal_error_function): Declare using
diagnostic_context typedef.
2010-10-05 Olivier Hainque <hainque@adacore.com>
Nicolas Roche <roche@adacore.com>

View File

@ -2325,7 +2325,7 @@ lto-symtab.o: lto-symtab.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(LTO_STREAMER_H) $(LINKER_PLUGIN_API_H) gt-lto-symtab.h
lto-opts.o: lto-opts.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
$(HASHTAB_H) $(GGC_H) $(BITMAP_H) $(FLAGS_H) opts.h options.h \
$(TARGET_H) $(TOPLEV_H) $(DIAGNOSTIC_CORE_H) $(LTO_STREAMER_H)
$(TARGET_H) $(TOPLEV_H) $(DIAGNOSTIC_H) $(LTO_STREAMER_H)
lto-streamer.o: lto-streamer.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
$(TM_H) $(TREE_H) $(GIMPLE_H) $(BITMAP_H) $(LTO_STREAMER_H) $(FLAGS_H) \
$(TREE_FLOW_H) $(DIAGNOSTIC_CORE_H) $(LTO_SYMTAB_H) $(TOPLEV_H) $(DIAGNOSTIC_CORE_H)

View File

@ -1,3 +1,11 @@
2010-10-05 Joseph Myers <joseph@codesourcery.com>
* c-common.h (struct diagnostic_context): Don't declare here.
(c_common_initialize_diagnostics): Declare using
diagnostic_context typedef.
* c-opts.c (c_common_handle_option): Pass global_dc to
handle_generated_option.
2010-10-04 Joseph Myers <joseph@codesourcery.com>
* c-opts.c (c_common_handle_option): Pass &global_options_set to

View File

@ -740,10 +740,8 @@ extern void set_compound_literal_name (tree decl);
extern tree build_va_arg (location_t, tree, tree);
struct diagnostic_context;
extern unsigned int c_common_option_lang_mask (void);
extern void c_common_initialize_diagnostics (struct diagnostic_context *);
extern void c_common_initialize_diagnostics (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 **);

View File

@ -438,7 +438,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
set_Wformat (value);
handle_generated_option (&global_options, &global_options_set,
OPT_Wimplicit, NULL, value,
c_family_lang_mask, kind, handlers);
c_family_lang_mask, kind, handlers, global_dc);
warn_char_subscripts = value;
warn_missing_braces = value;
warn_parentheses = value;
@ -533,11 +533,13 @@ c_common_handle_option (size_t scode, const char *arg, int value,
if (warn_implicit_int == -1)
handle_generated_option (&global_options, &global_options_set,
OPT_Wimplicit_int, NULL, value,
c_family_lang_mask, kind, handlers);
c_family_lang_mask, kind, handlers,
global_dc);
if (warn_implicit_function_declaration == -1)
handle_generated_option (&global_options, &global_options_set,
OPT_Wimplicit_function_declaration, NULL,
value, c_family_lang_mask, kind, handlers);
value, c_family_lang_mask, kind, handlers,
global_dc);
break;
case OPT_Winvalid_pch:

View File

@ -70,6 +70,8 @@ struct cl_optimization;
struct cl_option;
struct cl_decoded_option;
struct cl_option_handlers;
struct diagnostic_context;
typedef struct diagnostic_context diagnostic_context;
struct gimple_seq_d;
typedef struct gimple_seq_d *gimple_seq;
typedef const struct gimple_seq_d *const_gimple_seq;

View File

@ -1,3 +1,9 @@
2010-10-05 Joseph Myers <joseph@codesourcery.com>
* cp-tree.h (cxx_print_error_function,
cxx_initialize_diagnostics): Declare using diagnostic_context
typedef.
2010-10-04 Andi Kleen <ak@linux.intel.com>
* Make-lang.in (g++, cc1plus): Add + to build rule.

View File

@ -5430,7 +5430,7 @@ extern void cxx_print_xnode (FILE *, tree, int);
extern void cxx_print_decl (FILE *, tree, int);
extern void cxx_print_type (FILE *, tree, int);
extern void cxx_print_identifier (FILE *, tree, int);
extern void cxx_print_error_function (struct diagnostic_context *,
extern void cxx_print_error_function (diagnostic_context *,
const char *,
struct diagnostic_info *);
@ -5594,7 +5594,7 @@ extern alias_set_type cxx_get_alias_set (tree);
extern bool cxx_warn_unused_global_decl (const_tree);
extern size_t cp_tree_size (enum tree_code);
extern bool cp_var_mod_type_p (tree, tree);
extern void cxx_initialize_diagnostics (struct diagnostic_context *);
extern void cxx_initialize_diagnostics (diagnostic_context *);
extern int cxx_types_compatible_p (tree, tree);
extern void init_shadowed_var_for_decl (void);

View File

@ -52,7 +52,6 @@ typedef struct diagnostic_classification_change_t
} diagnostic_classification_change_t;
/* Forward declarations. */
typedef struct diagnostic_context diagnostic_context;
typedef void (*diagnostic_starter_fn) (diagnostic_context *,
diagnostic_info *);
typedef diagnostic_starter_fn diagnostic_finalizer_fn;

View File

@ -3806,7 +3806,8 @@ process_command (unsigned int decoded_options_count,
}
read_cmdline_option (&global_options, &global_options_set,
decoded_options + j, CL_DRIVER, &handlers);
decoded_options + j, CL_DRIVER, &handlers,
global_dc);
}
/* If -save-temps=obj and -o name, create the prefix to use for %b.

View File

@ -24,7 +24,6 @@ along with GCC; see the file COPYING3. If not see
#include "hooks.h"
struct diagnostic_context;
struct diagnostic_info;
/* Note to creators of new hooks:
@ -51,7 +50,7 @@ extern void lhd_print_tree_nothing (FILE *, tree, int);
extern const char *lhd_decl_printable_name (tree, int);
extern const char *lhd_dwarf_name (tree, int);
extern int lhd_types_compatible_p (tree, tree);
extern void lhd_print_error_function (struct diagnostic_context *,
extern void lhd_print_error_function (diagnostic_context *,
const char *, struct diagnostic_info *);
extern void lhd_set_decl_assembler_name (tree);
extern bool lhd_warn_unused_global_decl (const_tree);
@ -65,7 +64,7 @@ extern tree lhd_expr_to_decl (tree, bool *, bool *);
extern tree lhd_builtin_function (tree);
/* Declarations of default tree inlining hooks. */
extern void lhd_initialize_diagnostics (struct diagnostic_context *);
extern void lhd_initialize_diagnostics (diagnostic_context *);
extern void lhd_init_options (unsigned int,
struct cl_decoded_option *);
extern bool lhd_complain_wrong_lang_p (const struct cl_option *);

View File

@ -333,7 +333,7 @@ write_global_declarations (void)
/* Called to perform language-specific initialization of CTX. */
void
lhd_initialize_diagnostics (struct diagnostic_context *ctx ATTRIBUTE_UNUSED)
lhd_initialize_diagnostics (diagnostic_context *ctx ATTRIBUTE_UNUSED)
{
}

View File

@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see
/* This file should be #include-d after tree.h. */
struct diagnostic_context;
struct diagnostic_info;
struct gimplify_omp_ctx;
@ -275,7 +274,7 @@ struct lang_hooks
/* Callback used to perform language-specific initialization for the
global diagnostic context structure. */
void (*initialize_diagnostics) (struct diagnostic_context *);
void (*initialize_diagnostics) (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
@ -374,7 +373,7 @@ struct lang_hooks
int (*types_compatible_p) (tree x, tree y);
/* Called by report_error_function to print out function name. */
void (*print_error_function) (struct diagnostic_context *, const char *,
void (*print_error_function) (diagnostic_context *, const char *,
struct diagnostic_info *);
/* Convert a character from the host's to the target's character

View File

@ -31,7 +31,7 @@ along with GCC; see the file COPYING3. If not see
#include "opts.h"
#include "options.h"
#include "target.h"
#include "diagnostic-core.h"
#include "diagnostic.h"
#include "toplev.h"
#include "lto-streamer.h"
@ -404,7 +404,7 @@ lto_reissue_options (void)
if (flag_var)
set_option (&global_options, &global_options_set,
o->code, o->value, o->arg,
0 /*DK_UNSPECIFIED*/);
DK_UNSPECIFIED, global_dc);
if (o->type == CL_TARGET)
targetm.handle_option (o->code, o->arg, o->value);

View File

@ -804,7 +804,8 @@ keep:
option, DK_UNSPECIFIED otherwise. GENERATED_P is true for an
option generated as part of processing another option or otherwise
generated internally, false for one explicitly passed by the user.
Returns false if the switch was invalid. */
Returns false if the switch was invalid. DC is the diagnostic
context for options affecting diagnostics state, or NULL. */
bool
handle_option (struct gcc_options *opts,
@ -812,7 +813,7 @@ handle_option (struct gcc_options *opts,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers,
bool generated_p)
bool generated_p, diagnostic_context *dc)
{
size_t opt_index = decoded->opt_index;
const char *arg = decoded->arg;
@ -823,7 +824,7 @@ handle_option (struct gcc_options *opts,
if (flag_var)
set_option (opts, (generated_p ? NULL : opts_set),
opt_index, value, arg, kind);
opt_index, value, arg, kind, dc);
for (i = 0; i < handlers->num_handlers; i++)
if (option->flags & handlers->handlers[i].mask)
@ -849,13 +850,14 @@ handle_generated_option (struct gcc_options *opts,
struct gcc_options *opts_set,
size_t opt_index, const char *arg, int value,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers)
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
{
struct cl_decoded_option decoded;
generate_option (opt_index, arg, value, lang_mask, &decoded);
return handle_option (opts, opts_set, &decoded, lang_mask, kind, handlers,
true);
true, dc);
}
/* Fill in *DECODED with an option described by OPT_INDEX, ARG and
@ -915,14 +917,16 @@ generate_option_input_file (const char *file,
/* Handle the switch DECODED for the language indicated by LANG_MASK,
using the handlers in *HANDLERS and setting fields in OPTS and
OPTS_SET. */
OPTS_SET and using diagnostic context DC (if not NULL) for
diagnostic options. */
void
read_cmdline_option (struct gcc_options *opts,
struct gcc_options *opts_set,
struct cl_decoded_option *decoded,
unsigned int lang_mask,
const struct cl_option_handlers *handlers)
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
{
const struct cl_option *option;
const char *opt = decoded->orig_option_with_args_text;
@ -974,16 +978,19 @@ read_cmdline_option (struct gcc_options *opts,
gcc_assert (!decoded->errors);
if (!handle_option (opts, opts_set, decoded, lang_mask, DK_UNSPECIFIED,
handlers, false))
handlers, false, dc))
error ("unrecognized command line option %qs", opt);
}
/* Set any field in OPTS, and OPTS_SET if not NULL, for option
OPT_INDEX according to VALUE and ARG, diagnostic kind KIND. */
OPT_INDEX according to VALUE and ARG, diagnostic kind KIND, using
diagnostic context DC if not NULL for diagnostic
classification. */
void
set_option (struct gcc_options *opts, struct gcc_options *opts_set,
int opt_index, int value, const char *arg, int kind)
int opt_index, int value, const char *arg, int kind,
diagnostic_context *dc)
{
const struct cl_option *option = &cl_options[opt_index];
void *flag_var = option_flag_var (opt_index, opts);
@ -1028,8 +1035,9 @@ set_option (struct gcc_options *opts, struct gcc_options *opts_set,
break;
}
if ((diagnostic_t) kind != DK_UNSPECIFIED)
diagnostic_classify_diagnostic (global_dc, opt_index, (diagnostic_t) kind,
if ((diagnostic_t) kind != DK_UNSPECIFIED
&& dc != NULL)
diagnostic_classify_diagnostic (dc, opt_index, (diagnostic_t) kind,
UNKNOWN_LOCATION);
}

View File

@ -639,7 +639,8 @@ read_cmdline_options (struct cl_decoded_option *decoded_options,
}
read_cmdline_option (&global_options, &global_options_set,
decoded_options + i, lang_mask, handlers);
decoded_options + i, lang_mask, handlers,
global_dc);
}
}
@ -879,7 +880,8 @@ decode_options (unsigned int argc, const char **argv,
}
/* Enable -Werror=coverage-mismatch by default */
enable_warning_as_error ("coverage-mismatch", 1, lang_mask, &handlers);
enable_warning_as_error ("coverage-mismatch", 1, lang_mask, &handlers,
global_dc);
if (first_time_p)
{
@ -1606,7 +1608,7 @@ common_handle_option (struct gcc_options *opts,
break;
case OPT_Werror_:
enable_warning_as_error (arg, value, lang_mask, handlers);
enable_warning_as_error (arg, value, lang_mask, handlers, global_dc);
break;
case OPT_Wlarger_than_:
@ -2284,12 +2286,15 @@ register_warning_as_error_callback (void (*callback) (int))
warning_as_error_callback = callback;
}
/* Enable a warning option as an error. This is used by -Werror= and
also by legacy Werror-implicit-function-declaration. */
/* Enable (or disable if VALUE is 0) a warning option ARG (language
mask LANG_MASK, option handlers HANDLERS) as an error for
diagnostic context DC (possibly NULL). This is used by
-Werror=. */
void
enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
const struct cl_option_handlers *handlers)
const struct cl_option_handlers *handlers,
diagnostic_context *dc)
{
char *new_option;
int option_index;
@ -2311,8 +2316,9 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
option_index = option->alias_target;
if (option_index == OPT_SPECIAL_ignore)
return;
diagnostic_classify_diagnostic (global_dc, option_index, kind,
UNKNOWN_LOCATION);
if (dc)
diagnostic_classify_diagnostic (dc, option_index, kind,
UNKNOWN_LOCATION);
if (kind == DK_ERROR)
{
const struct cl_option * const option = cl_options + option_index;
@ -2321,7 +2327,8 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask,
if (option->var_type == CLVC_BOOLEAN)
handle_generated_option (&global_options, &global_options_set,
option_index, NULL, value, lang_mask,
(int)kind, handlers);
(int)kind, handlers,
dc);
if (warning_as_error_callback)
warning_as_error_callback (option_index);

View File

@ -216,19 +216,21 @@ extern bool get_option_state (struct gcc_options *, int,
struct cl_option_state *);
extern void set_option (struct gcc_options *opts,
struct gcc_options *opts_set,
int opt_index, int value, const char *arg, int);
int opt_index, int value, const char *arg, int kind,
diagnostic_context *dc);
extern void *option_flag_var (int opt_index, struct gcc_options *opts);
bool handle_option (struct gcc_options *opts,
struct gcc_options *opts_set,
const struct cl_decoded_option *decoded,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers,
bool generated_p);
bool generated_p, diagnostic_context *dc);
bool handle_generated_option (struct gcc_options *opts,
struct gcc_options *opts_set,
size_t opt_index, const char *arg, int value,
unsigned int lang_mask, int kind,
const struct cl_option_handlers *handlers);
const struct cl_option_handlers *handlers,
diagnostic_context *dc);
void generate_option (size_t opt_index, const char *arg, int value,
unsigned int lang_mask,
struct cl_decoded_option *decoded);
@ -238,10 +240,12 @@ extern void read_cmdline_option (struct gcc_options *opts,
struct gcc_options *opts_set,
struct cl_decoded_option *decoded,
unsigned int lang_mask,
const struct cl_option_handlers *handlers);
const struct cl_option_handlers *handlers,
diagnostic_context *dc);
extern void register_warning_as_error_callback (void (*callback) (int));
extern void enable_warning_as_error (const char *arg, int value,
unsigned int lang_mask,
const struct cl_option_handlers *handlers);
const struct cl_option_handlers *handlers,
diagnostic_context *dc);
extern void print_ignored_options (void);
#endif

View File

@ -830,7 +830,7 @@ warn_if_plugins (void)
/* Likewise, as a callback from the diagnostics code. */
void
plugins_internal_error_function (struct diagnostic_context *context ATTRIBUTE_UNUSED,
plugins_internal_error_function (diagnostic_context *context ATTRIBUTE_UNUSED,
const char *msgid ATTRIBUTE_UNUSED,
va_list *ap ATTRIBUTE_UNUSED)
{

View File

@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see
#include "gcc-plugin.h"
struct attribute_spec;
struct diagnostic_context;
extern void add_new_plugin (const char *);
extern void parse_plugin_arg_opt (const char *);
@ -33,7 +32,7 @@ extern bool plugins_active_p (void);
extern void dump_active_plugins (FILE *);
extern void debug_active_plugins (void);
extern void warn_if_plugins (void);
extern void plugins_internal_error_function (struct diagnostic_context *,
extern void plugins_internal_error_function (diagnostic_context *,
const char *, va_list *);
extern void print_plugins_versions (FILE *file, const char *indent);
extern void print_plugins_help (FILE *file, const char *indent);