summaryrefslogtreecommitdiff
path: root/gcc/opts.c
diff options
context:
space:
mode:
authorjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-26 13:40:53 +0000
committerjsm28 <jsm28@138bc75d-0d04-0410-961f-82ee72b054a4>2010-05-26 13:40:53 +0000
commit3c6a9715a98d0ee9da8bf24324d0a8a4bba990f0 (patch)
treecb4cbcf522a027e78291661bf1d98cb25d1f7585 /gcc/opts.c
parentabdd77b808b58f43030d78aa8ce6ef62d4b8bbbd (diff)
downloadgcc-3c6a9715a98d0ee9da8bf24324d0a8a4bba990f0.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159869 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/opts.c')
-rw-r--r--gcc/opts.c54
1 files changed, 53 insertions, 1 deletions
diff --git a/gcc/opts.c b/gcc/opts.c
index 2e788d28fdd..65121a4222e 100644
--- a/gcc/opts.c
+++ b/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;
+}