mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-02-25 23:26:16 +08:00
diagnostic.c: Don't include opts.h.
* diagnostic.c: Don't include opts.h. (permissive_error_option): Define. (diagnostic_initialize): Take n_opts parameter. Allocate memory for classify_diagnostic. Don't use memset for classify_diagnostic. Initialize new and recently added fields. (diagnostic_classify_diagnostic): Use context->n_opts instead of N_OPTS. (diagnostic_report_diagnostic): Pass context parameter to diagnostic_report_warnings_p. Use option_enabled and option_name hooks from context. (emit_diagnostic): Use permissive_error_option. (permerror): Likewise. * diagnostic.h: Don't include options.h. (struct diagnostic_context): Add n_opts, opt_permissive, inhibit_warnings, warn_system_headers, option_enabled and option_name fields. Change classify_diagnostic to a pointer. * opts-diagnostic.h: New file. * opts.c: Include opts-diagnostic.h. (common_handle_option): Set global_dc fields for -Wfatal-errors, -Wsystem-headers, -fshow-column, -pedantic-errors and -w. (option_name): New function. * c-opts.c (c_common_init_options): Set global_dc->opt_permissive. (c_common_handle_option): Set global_dc->permissive for -fpermissive. * c-common.c (c_cpp_error): Save and restore global_dc->warn_system_headers, not variable warn_system_headers. * toplev.c: Include opts-diagnostic.h. (general_init): Update call to diagnostic_initialize. Set global_dc->show_column, global_dc->option_enabled and global_dc->option_name. (process_options): Don't set global_dc fields here. * Makefile.in (DIAGNOSTIC_H): Remove options.h. (diagnostic.o, opts.o, toplev.o): Update dependencies. fortran: * cpp.c (cb_cpp_error): Save and restore global_dc->warn_system_headers, not variable warn_system_headers. From-SVN: r159869
This commit is contained in:
parent
f024f85d3d
commit
5f0f4a3bc5
@ -1,3 +1,39 @@
|
||||
2010-05-26 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* diagnostic.c: Don't include opts.h.
|
||||
(permissive_error_option): Define.
|
||||
(diagnostic_initialize): Take n_opts parameter. Allocate memory
|
||||
for classify_diagnostic. Don't use memset for
|
||||
classify_diagnostic. Initialize new and recently added fields.
|
||||
(diagnostic_classify_diagnostic): Use context->n_opts instead of
|
||||
N_OPTS.
|
||||
(diagnostic_report_diagnostic): Pass context parameter to
|
||||
diagnostic_report_warnings_p. Use option_enabled and option_name
|
||||
hooks from context.
|
||||
(emit_diagnostic): Use permissive_error_option.
|
||||
(permerror): Likewise.
|
||||
* diagnostic.h: Don't include options.h.
|
||||
(struct diagnostic_context): Add n_opts, opt_permissive,
|
||||
inhibit_warnings, warn_system_headers, option_enabled and
|
||||
option_name fields. Change classify_diagnostic to a pointer.
|
||||
* opts-diagnostic.h: New file.
|
||||
* opts.c: Include opts-diagnostic.h.
|
||||
(common_handle_option): Set global_dc fields for -Wfatal-errors,
|
||||
-Wsystem-headers, -fshow-column, -pedantic-errors and -w.
|
||||
(option_name): New function.
|
||||
* c-opts.c (c_common_init_options): Set global_dc->opt_permissive.
|
||||
(c_common_handle_option): Set global_dc->permissive for
|
||||
-fpermissive.
|
||||
* c-common.c (c_cpp_error): Save and restore
|
||||
global_dc->warn_system_headers, not variable warn_system_headers.
|
||||
* toplev.c: Include opts-diagnostic.h.
|
||||
(general_init): Update call to diagnostic_initialize. Set
|
||||
global_dc->show_column, global_dc->option_enabled and
|
||||
global_dc->option_name.
|
||||
(process_options): Don't set global_dc fields here.
|
||||
* Makefile.in (DIAGNOSTIC_H): Remove options.h.
|
||||
(diagnostic.o, opts.o, toplev.o): Update dependencies.
|
||||
|
||||
2010-04-30 Hariharan Sandanagobalane <hariharan@picochip.com>
|
||||
|
||||
* config/picochip/picochip.md (movsi): Split a movsi from a
|
||||
|
@ -942,7 +942,7 @@ TREE_SSA_LIVE_H = tree-ssa-live.h $(PARTITION_H) vecprim.h
|
||||
TREE_VECTORIZER_H = tree-vectorizer.h $(TREE_DATA_REF_H)
|
||||
SSAEXPAND_H = ssaexpand.h $(TREE_SSA_LIVE_H)
|
||||
PRETTY_PRINT_H = pretty-print.h $(INPUT_H) $(OBSTACK_H)
|
||||
DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H) options.h
|
||||
DIAGNOSTIC_H = diagnostic.h diagnostic.def $(PRETTY_PRINT_H)
|
||||
C_PRETTY_PRINT_H = c-pretty-print.h $(PRETTY_PRINT_H) $(C_COMMON_H) $(TREE_H)
|
||||
SCEV_H = tree-scalar-evolution.h $(GGC_H) tree-chrec.h $(PARAMS_H)
|
||||
LAMBDA_H = lambda.h $(TREE_H) vec.h $(GGC_H)
|
||||
@ -2735,12 +2735,12 @@ fold-const.o : fold-const.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
|
||||
$(GIMPLE_H) realmpfr.h
|
||||
diagnostic.o : diagnostic.c $(CONFIG_H) $(SYSTEM_H) coretypes.h \
|
||||
version.h $(INPUT_H) $(TOPLEV_H) intl.h $(DIAGNOSTIC_H) \
|
||||
diagnostic.def opts.h
|
||||
diagnostic.def
|
||||
opts.o : opts.c opts.h options.h $(TOPLEV_H) $(CONFIG_H) $(SYSTEM_H) \
|
||||
coretypes.h $(TREE_H) $(TM_H) langhooks.h $(GGC_H) $(EXPR_H) $(RTL_H) \
|
||||
output.h $(DIAGNOSTIC_H) $(TM_P_H) $(INSN_ATTR_H) intl.h $(TARGET_H) \
|
||||
$(FLAGS_H) $(PARAMS_H) $(TREE_PASS_H) $(DBGCNT_H) debug.h \
|
||||
$(PLUGIN_H) $(EXCEPT_H) $(LTO_STREAMER_H)
|
||||
$(PLUGIN_H) $(EXCEPT_H) $(LTO_STREAMER_H) opts-diagnostic.h
|
||||
opts-common.o : opts-common.c opts.h $(CONFIG_H) $(SYSTEM_H) \
|
||||
coretypes.h intl.h
|
||||
targhooks.o : targhooks.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TREE_H) \
|
||||
@ -2766,7 +2766,7 @@ toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) \
|
||||
$(CGRAPH_H) $(COVERAGE_H) alloc-pool.h $(GGC_H) $(INTEGRATE_H) \
|
||||
opts.h params.def tree-mudflap.h $(TREE_PASS_H) $(GIMPLE_H) \
|
||||
tree-ssa-alias.h $(PLUGIN_H) realmpfr.h tree-diagnostic.h \
|
||||
tree-pretty-print.h
|
||||
tree-pretty-print.h opts-diagnostic.h
|
||||
$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
|
||||
-DTARGET_NAME=\"$(target_noncanonical)\" \
|
||||
-c $(srcdir)/toplev.c $(OUTPUT_OPTION)
|
||||
|
@ -8364,7 +8364,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
|
||||
{
|
||||
diagnostic_info diagnostic;
|
||||
diagnostic_t dlevel;
|
||||
int save_warn_system_headers = warn_system_headers;
|
||||
bool save_warn_system_headers = global_dc->warn_system_headers;
|
||||
bool ret;
|
||||
|
||||
switch (level)
|
||||
@ -8372,7 +8372,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
|
||||
case CPP_DL_WARNING_SYSHDR:
|
||||
if (flag_no_output)
|
||||
return false;
|
||||
warn_system_headers = 1;
|
||||
global_dc->warn_system_headers = 1;
|
||||
/* Fall through. */
|
||||
case CPP_DL_WARNING:
|
||||
if (flag_no_output)
|
||||
@ -8409,7 +8409,7 @@ c_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
|
||||
c_option_controlling_cpp_error (reason));
|
||||
ret = report_diagnostic (&diagnostic);
|
||||
if (level == CPP_DL_WARNING_SYSHDR)
|
||||
warn_system_headers = save_warn_system_headers;
|
||||
global_dc->warn_system_headers = save_warn_system_headers;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -304,6 +304,8 @@ c_common_init_options (unsigned int argc, const char **argv)
|
||||
diagnostic_prefixing_rule (global_dc) = DIAGNOSTICS_SHOW_PREFIX_ONCE;
|
||||
}
|
||||
|
||||
global_dc->opt_permissive = OPT_fpermissive;
|
||||
|
||||
parse_in = cpp_create_reader (c_dialect_cxx () ? CLK_GNUCXX: CLK_GNUC89,
|
||||
ident_hash, line_table);
|
||||
cb = cpp_get_callbacks (parse_in);
|
||||
@ -848,7 +850,7 @@ c_common_handle_option (size_t scode, const char *arg, int value,
|
||||
break;
|
||||
|
||||
case OPT_fpermissive:
|
||||
flag_permissive = value;
|
||||
global_dc->permissive = flag_permissive = value;
|
||||
break;
|
||||
|
||||
case OPT_fpreprocessed:
|
||||
|
@ -31,11 +31,11 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "toplev.h"
|
||||
#include "intl.h"
|
||||
#include "diagnostic.h"
|
||||
#include "opts.h"
|
||||
|
||||
#define pedantic_warning_kind(DC) \
|
||||
((DC)->pedantic_errors ? DK_ERROR : DK_WARNING)
|
||||
#define permissive_error_kind(DC) ((DC)->permissive ? DK_WARNING : DK_ERROR)
|
||||
#define permissive_error_option(DC) ((DC)->opt_permissive)
|
||||
|
||||
/* Prototypes. */
|
||||
static char *build_message_string (const char *, ...) ATTRIBUTE_PRINTF_1;
|
||||
@ -77,8 +77,10 @@ file_name_as_prefix (const char *f)
|
||||
|
||||
/* Initialize the diagnostic message outputting machinery. */
|
||||
void
|
||||
diagnostic_initialize (diagnostic_context *context)
|
||||
diagnostic_initialize (diagnostic_context *context, int n_opts)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Allocate a basic pretty-printer. Clients will replace this a
|
||||
much more elaborated pretty-printer if they wish. */
|
||||
context->printer = XNEW (pretty_printer);
|
||||
@ -91,13 +93,24 @@ diagnostic_initialize (diagnostic_context *context)
|
||||
memset (context->diagnostic_count, 0, sizeof context->diagnostic_count);
|
||||
context->some_warnings_are_errors = false;
|
||||
context->warning_as_error_requested = false;
|
||||
memset (context->classify_diagnostic, DK_UNSPECIFIED,
|
||||
sizeof context->classify_diagnostic);
|
||||
context->n_opts = n_opts;
|
||||
context->classify_diagnostic = XNEWVEC (diagnostic_t, n_opts);
|
||||
for (i = 0; i < n_opts; i++)
|
||||
context->classify_diagnostic[i] = DK_UNSPECIFIED;
|
||||
context->show_option_requested = false;
|
||||
context->abort_on_error = false;
|
||||
context->show_column = false;
|
||||
context->pedantic_errors = false;
|
||||
context->permissive = false;
|
||||
context->opt_permissive = 0;
|
||||
context->fatal_errors = false;
|
||||
context->inhibit_warnings = false;
|
||||
context->warn_system_headers = false;
|
||||
context->internal_error = NULL;
|
||||
diagnostic_starter (context) = default_diagnostic_starter;
|
||||
diagnostic_finalizer (context) = default_diagnostic_finalizer;
|
||||
context->option_enabled = NULL;
|
||||
context->option_name = NULL;
|
||||
context->last_module = 0;
|
||||
context->x_data = NULL;
|
||||
context->lock = 0;
|
||||
@ -295,7 +308,7 @@ diagnostic_classify_diagnostic (diagnostic_context *context,
|
||||
diagnostic_t old_kind;
|
||||
|
||||
if (option_index <= 0
|
||||
|| option_index >= N_OPTS
|
||||
|| option_index >= context->n_opts
|
||||
|| new_kind >= DK_LAST_DIAGNOSTIC_KIND)
|
||||
return DK_UNSPECIFIED;
|
||||
|
||||
@ -322,7 +335,7 @@ diagnostic_report_diagnostic (diagnostic_context *context,
|
||||
/* Give preference to being able to inhibit warnings, before they
|
||||
get reclassified to something else. */
|
||||
if ((diagnostic->kind == DK_WARNING || diagnostic->kind == DK_PEDWARN)
|
||||
&& !diagnostic_report_warnings_p (location))
|
||||
&& !diagnostic_report_warnings_p (context, location))
|
||||
return false;
|
||||
|
||||
if (diagnostic->kind == DK_PEDWARN)
|
||||
@ -360,7 +373,7 @@ diagnostic_report_diagnostic (diagnostic_context *context,
|
||||
{
|
||||
/* This tests if the user provided the appropriate -Wfoo or
|
||||
-Wno-foo option. */
|
||||
if (! option_enabled (diagnostic->option_index))
|
||||
if (! context->option_enabled (diagnostic->option_index))
|
||||
return false;
|
||||
/* This tests if the user provided the appropriate -Werror=foo
|
||||
option. */
|
||||
@ -405,38 +418,20 @@ diagnostic_report_diagnostic (diagnostic_context *context,
|
||||
saved_format_spec = diagnostic->message.format_spec;
|
||||
if (context->show_option_requested)
|
||||
{
|
||||
const char * option_text = NULL;
|
||||
char *option_text;
|
||||
|
||||
if (diagnostic->option_index)
|
||||
{
|
||||
/* A warning classified as an error. */
|
||||
if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN)
|
||||
&& diagnostic->kind == DK_ERROR)
|
||||
option_text
|
||||
= ACONCAT ((cl_options[OPT_Werror_].opt_text,
|
||||
/* Skip over "-W". */
|
||||
cl_options[diagnostic->option_index].opt_text + 2,
|
||||
NULL));
|
||||
/* A warning with option. */
|
||||
else
|
||||
option_text = cl_options[diagnostic->option_index].opt_text;
|
||||
}
|
||||
/* A warning without option classified as an error. */
|
||||
else if (orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN
|
||||
|| diagnostic->kind == DK_WARNING)
|
||||
{
|
||||
if (context->warning_as_error_requested)
|
||||
option_text = cl_options[OPT_Werror].opt_text;
|
||||
else
|
||||
option_text = _("enabled by default");
|
||||
}
|
||||
option_text = context->option_name (context, diagnostic->option_index,
|
||||
orig_diag_kind, diagnostic->kind);
|
||||
|
||||
if (option_text)
|
||||
diagnostic->message.format_spec
|
||||
= ACONCAT ((diagnostic->message.format_spec,
|
||||
" ",
|
||||
"[", option_text, "]",
|
||||
NULL));
|
||||
{
|
||||
diagnostic->message.format_spec
|
||||
= ACONCAT ((diagnostic->message.format_spec,
|
||||
" ",
|
||||
"[", option_text, "]",
|
||||
NULL));
|
||||
free (option_text);
|
||||
}
|
||||
}
|
||||
diagnostic->message.locus = &diagnostic->location;
|
||||
diagnostic->message.x_data = &diagnostic->x_data;
|
||||
@ -519,7 +514,7 @@ emit_diagnostic (diagnostic_t kind, location_t location, int opt,
|
||||
{
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
|
||||
permissive_error_kind (global_dc));
|
||||
diagnostic.option_index = OPT_fpermissive;
|
||||
diagnostic.option_index = permissive_error_option (global_dc);
|
||||
}
|
||||
else {
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, location, kind);
|
||||
@ -638,7 +633,7 @@ permerror (location_t location, const char *gmsgid, ...)
|
||||
va_start (ap, gmsgid);
|
||||
diagnostic_set_info (&diagnostic, gmsgid, &ap, location,
|
||||
permissive_error_kind (global_dc));
|
||||
diagnostic.option_index = OPT_fpermissive;
|
||||
diagnostic.option_index = permissive_error_option (global_dc);
|
||||
va_end (ap);
|
||||
return report_diagnostic (&diagnostic);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ along with GCC; see the file COPYING3. If not see
|
||||
#define GCC_DIAGNOSTIC_H
|
||||
|
||||
#include "pretty-print.h"
|
||||
#include "options.h"
|
||||
|
||||
/* Constants used to discriminate diagnostics. */
|
||||
typedef enum
|
||||
@ -73,12 +72,17 @@ struct diagnostic_context
|
||||
/* True if it has been requested that warnings be treated as errors. */
|
||||
bool warning_as_error_requested;
|
||||
|
||||
/* For each option index that can be passed to warning() et all
|
||||
(OPT_* from options.h), this array may contain a new kind that
|
||||
the diagnostic should be changed to before reporting, or
|
||||
DK_UNSPECIFIED to leave it as the reported kind, or DK_IGNORED to
|
||||
not report it at all. N_OPTS is from <options.h>. */
|
||||
diagnostic_t classify_diagnostic[N_OPTS];
|
||||
/* The number of option indexes that can be passed to warning() et
|
||||
al. */
|
||||
int n_opts;
|
||||
|
||||
/* For each option index that can be passed to warning() et al
|
||||
(OPT_* from options.h when using this code with the core GCC
|
||||
options), this array may contain a new kind that the diagnostic
|
||||
should be changed to before reporting, or DK_UNSPECIFIED to leave
|
||||
it as the reported kind, or DK_IGNORED to not report it at
|
||||
all. */
|
||||
diagnostic_t *classify_diagnostic;
|
||||
|
||||
/* True if we should print the command line option which controls
|
||||
each diagnostic, if known. */
|
||||
@ -96,9 +100,19 @@ struct diagnostic_context
|
||||
/* True if permerrors are warnings. */
|
||||
bool permissive;
|
||||
|
||||
/* The index of the option to associate with turning permerrors into
|
||||
warnings. */
|
||||
int opt_permissive;
|
||||
|
||||
/* True if errors are fatal. */
|
||||
bool fatal_errors;
|
||||
|
||||
/* True if all warnings should be disabled. */
|
||||
bool inhibit_warnings;
|
||||
|
||||
/* True if warnings should be given in system headers. */
|
||||
bool warn_system_headers;
|
||||
|
||||
/* This function is called before any message is printed out. It is
|
||||
responsible for preparing message prefix and such. For example, it
|
||||
might say:
|
||||
@ -114,6 +128,18 @@ struct diagnostic_context
|
||||
/* Client hook to report an internal error. */
|
||||
void (*internal_error) (diagnostic_context *, const char *, va_list *);
|
||||
|
||||
/* Client hook to say whether the option controlling a diagnostic is
|
||||
enabled. Returns nonzero if enabled, zero if disabled. */
|
||||
int (*option_enabled) (int);
|
||||
|
||||
/* Client hook to return the name of an option that controls a
|
||||
diagnostic. Returns malloced memory. The first diagnostic_t
|
||||
argument is the kind of diagnostic before any reclassification
|
||||
(of warnings as errors, etc.); the second is the kind after any
|
||||
reclassification. May return NULL if no name is to be printed.
|
||||
May be passed 0 as well as the index of a particular option. */
|
||||
char *(*option_name) (diagnostic_context *, int, diagnostic_t, diagnostic_t);
|
||||
|
||||
/* Auxiliary data for client. */
|
||||
void *x_data;
|
||||
|
||||
@ -187,9 +213,9 @@ extern diagnostic_context *global_dc;
|
||||
#define sorrycount diagnostic_kind_count (global_dc, DK_SORRY)
|
||||
|
||||
/* Returns nonzero if warnings should be emitted. */
|
||||
#define diagnostic_report_warnings_p(LOC) \
|
||||
(!inhibit_warnings \
|
||||
&& !(in_system_header_at (LOC) && !warn_system_headers))
|
||||
#define diagnostic_report_warnings_p(DC, LOC) \
|
||||
(!(DC)->inhibit_warnings \
|
||||
&& !(in_system_header_at (LOC) && !(DC)->warn_system_headers))
|
||||
|
||||
#define report_diagnostic(D) diagnostic_report_diagnostic (global_dc, D)
|
||||
|
||||
@ -203,7 +229,7 @@ extern diagnostic_context *global_dc;
|
||||
((DI)->option_index = (OPTIDX))
|
||||
|
||||
/* Diagnostic related functions. */
|
||||
extern void diagnostic_initialize (diagnostic_context *);
|
||||
extern void diagnostic_initialize (diagnostic_context *, int);
|
||||
extern void diagnostic_finish (diagnostic_context *);
|
||||
extern void diagnostic_report_current_module (diagnostic_context *);
|
||||
|
||||
|
@ -1,3 +1,8 @@
|
||||
2010-05-26 Joseph Myers <joseph@codesourcery.com>
|
||||
|
||||
* cpp.c (cb_cpp_error): Save and restore
|
||||
global_dc->warn_system_headers, not variable warn_system_headers.
|
||||
|
||||
2010-05-26 Steven Bosscher <steven@gcc.gnu.org>
|
||||
|
||||
* fortran/f95-lang.c: Do not include libfuncs.h, expr.h, and except.h.
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2008, 2009 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
@ -975,13 +975,13 @@ cb_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
|
||||
{
|
||||
diagnostic_info diagnostic;
|
||||
diagnostic_t dlevel;
|
||||
int save_warn_system_headers = warn_system_headers;
|
||||
bool save_warn_system_headers = global_dc->warn_system_headers;
|
||||
bool ret;
|
||||
|
||||
switch (level)
|
||||
{
|
||||
case CPP_DL_WARNING_SYSHDR:
|
||||
warn_system_headers = 1;
|
||||
global_dc->warn_system_headers = 1;
|
||||
/* Fall through. */
|
||||
case CPP_DL_WARNING:
|
||||
dlevel = DK_WARNING;
|
||||
@ -1012,7 +1012,7 @@ cb_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
|
||||
diagnostic_override_option_index (&diagnostic, OPT_Wcpp);
|
||||
ret = report_diagnostic (&diagnostic);
|
||||
if (level == CPP_DL_WARNING_SYSHDR)
|
||||
warn_system_headers = save_warn_system_headers;
|
||||
global_dc->warn_system_headers = save_warn_system_headers;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
25
gcc/opts-diagnostic.h
Normal file
25
gcc/opts-diagnostic.h
Normal file
@ -0,0 +1,25 @@
|
||||
/* Command line option handling. Interactions with diagnostics code.
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GCC.
|
||||
|
||||
GCC is free software; you can redistribute it and/or modify it under
|
||||
the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 3, or (at your option) any later
|
||||
version.
|
||||
|
||||
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GCC; see the file COPYING3. If not see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef GCC_OPTS_DIAGNOSTIC_H
|
||||
#define GCC_OPTS_DIAGNOSTIC_H
|
||||
|
||||
extern char *option_name (diagnostic_context *context, int option_index,
|
||||
diagnostic_t orig_diag_kind, diagnostic_t diag_kind);
|
||||
#endif
|
54
gcc/opts.c
54
gcc/opts.c
@ -36,6 +36,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "toplev.h"
|
||||
#include "params.h"
|
||||
#include "diagnostic.h"
|
||||
#include "opts-diagnostic.h"
|
||||
#include "tm_p.h" /* For OPTIMIZATION_OPTIONS. */
|
||||
#include "insn-attr.h" /* For INSN_SCHEDULING. */
|
||||
#include "target.h"
|
||||
@ -1703,6 +1704,10 @@ common_handle_option (size_t scode, const char *arg, int value,
|
||||
warn_larger_than = value != -1;
|
||||
break;
|
||||
|
||||
case OPT_Wfatal_errors:
|
||||
global_dc->fatal_errors = value;
|
||||
break;
|
||||
|
||||
case OPT_Wframe_larger_than_:
|
||||
frame_larger_than_size = value;
|
||||
warn_frame_larger_than = value != -1;
|
||||
@ -1726,6 +1731,10 @@ common_handle_option (size_t scode, const char *arg, int value,
|
||||
warn_strict_overflow = value;
|
||||
break;
|
||||
|
||||
case OPT_Wsystem_headers:
|
||||
global_dc->warn_system_headers = value;
|
||||
break;
|
||||
|
||||
case OPT_Wunused:
|
||||
warn_unused = value;
|
||||
break;
|
||||
@ -1955,6 +1964,10 @@ common_handle_option (size_t scode, const char *arg, int value,
|
||||
flag_profile_values_set = true;
|
||||
break;
|
||||
|
||||
case OPT_fshow_column:
|
||||
global_dc->show_column = value;
|
||||
break;
|
||||
|
||||
case OPT_fvisibility_:
|
||||
{
|
||||
if (!strcmp(arg, "default"))
|
||||
@ -2168,13 +2181,17 @@ common_handle_option (size_t scode, const char *arg, int value,
|
||||
break;
|
||||
|
||||
case OPT_pedantic_errors:
|
||||
flag_pedantic_errors = pedantic = 1;
|
||||
global_dc->pedantic_errors = flag_pedantic_errors = pedantic = 1;
|
||||
break;
|
||||
|
||||
case OPT_fwhopr:
|
||||
flag_whopr = value;
|
||||
break;
|
||||
|
||||
case OPT_w:
|
||||
global_dc->inhibit_warnings = true;
|
||||
break;
|
||||
|
||||
case OPT_fsee:
|
||||
case OPT_fcse_skip_blocks:
|
||||
case OPT_floop_optimize:
|
||||
@ -2510,3 +2527,38 @@ enable_warning_as_error (const char *arg, int value, unsigned int lang_mask)
|
||||
}
|
||||
free (new_option);
|
||||
}
|
||||
|
||||
/* Return malloced memory for the name of the option OPTION_INDEX
|
||||
which enabled a diagnostic (context CONTEXT), originally of type
|
||||
ORIG_DIAG_KIND but possibly converted to DIAG_KIND by options such
|
||||
as -Werror. */
|
||||
|
||||
char *
|
||||
option_name (diagnostic_context *context, int option_index,
|
||||
diagnostic_t orig_diag_kind, diagnostic_t diag_kind)
|
||||
{
|
||||
if (option_index)
|
||||
{
|
||||
/* A warning classified as an error. */
|
||||
if ((orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN)
|
||||
&& diag_kind == DK_ERROR)
|
||||
return concat (cl_options[OPT_Werror_].opt_text,
|
||||
/* Skip over "-W". */
|
||||
cl_options[option_index].opt_text + 2,
|
||||
NULL);
|
||||
/* A warning with option. */
|
||||
else
|
||||
return xstrdup (cl_options[option_index].opt_text);
|
||||
}
|
||||
/* A warning without option classified as an error. */
|
||||
else if (orig_diag_kind == DK_WARNING || orig_diag_kind == DK_PEDWARN
|
||||
|| diag_kind == DK_WARNING)
|
||||
{
|
||||
if (context->warning_as_error_requested)
|
||||
return xstrdup (cl_options[OPT_Werror].opt_text);
|
||||
else
|
||||
return xstrdup (_("enabled by default"));
|
||||
}
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
11
gcc/toplev.c
11
gcc/toplev.c
@ -78,6 +78,7 @@ along with GCC; see the file COPYING3. If not see
|
||||
#include "hosthooks.h"
|
||||
#include "cgraph.h"
|
||||
#include "opts.h"
|
||||
#include "opts-diagnostic.h"
|
||||
#include "coverage.h"
|
||||
#include "value-prof.h"
|
||||
#include "alloc-pool.h"
|
||||
@ -1691,13 +1692,16 @@ general_init (const char *argv0)
|
||||
|
||||
/* Initialize the diagnostics reporting machinery, so option parsing
|
||||
can give warnings and errors. */
|
||||
diagnostic_initialize (global_dc);
|
||||
diagnostic_initialize (global_dc, N_OPTS);
|
||||
diagnostic_starter (global_dc) = default_tree_diagnostic_starter;
|
||||
/* Set a default printer. Language specific initializations will
|
||||
override it later. */
|
||||
pp_format_decoder (global_dc->printer) = &default_tree_printer;
|
||||
global_dc->show_option_requested = flag_diagnostics_show_option;
|
||||
global_dc->show_column = flag_show_column;
|
||||
global_dc->internal_error = plugins_internal_error_function;
|
||||
global_dc->option_enabled = option_enabled;
|
||||
global_dc->option_name = option_name;
|
||||
|
||||
/* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages. */
|
||||
#ifdef SIGSEGV
|
||||
@ -1828,11 +1832,6 @@ process_options (void)
|
||||
if (flag_compare_debug)
|
||||
diagnostic_inhibit_notes (global_dc);
|
||||
|
||||
global_dc->show_column = flag_show_column;
|
||||
global_dc->pedantic_errors = flag_pedantic_errors;
|
||||
global_dc->permissive = flag_permissive;
|
||||
global_dc->fatal_errors = flag_fatal_errors;
|
||||
|
||||
if (flag_section_anchors && !target_supports_section_anchors_p ())
|
||||
{
|
||||
warning (OPT_fsection_anchors,
|
||||
|
Loading…
Reference in New Issue
Block a user