diff options
author | DJ Delorie <dj@redhat.com> | 2005-05-03 21:36:13 -0400 |
---|---|---|
committer | DJ Delorie <dj@gcc.gnu.org> | 2005-05-03 21:36:13 -0400 |
commit | 2098fe9ed59d4342ee62ae9f796242a0683d8643 (patch) | |
tree | 02e58ad626b4c528bb00fa48493c8680b37ca246 /gcc | |
parent | 9791c75c41eb16f99b6a3e9456e823777a36d061 (diff) | |
download | gcc-2098fe9ed59d4342ee62ae9f796242a0683d8643.zip gcc-2098fe9ed59d4342ee62ae9f796242a0683d8643.tar.gz gcc-2098fe9ed59d4342ee62ae9f796242a0683d8643.tar.bz2 |
common.opt (fdiagnostics-show-option): No variable is needed.
* common.opt (fdiagnostics-show-option): No variable is needed.
* diagnostic.h (diagnostic_context): Add show_option_requested flag.
* diagnostic.c (diagnostic_initialize): Initialize show_option_requested.
(diagnostic_report_diagnostic): Test for enabled diagnostics here.
Save and restore original message format. Use flag in context
instead of global.
(warning): Don't test for enabled warnings here.
* opts.c (common_handle_option): Handle -fdiagnostics-show-option
here.
From-SVN: r99204
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 12 | ||||
-rw-r--r-- | gcc/common.opt | 2 | ||||
-rw-r--r-- | gcc/diagnostic.c | 13 | ||||
-rw-r--r-- | gcc/diagnostic.h | 4 | ||||
-rw-r--r-- | gcc/opts.c | 4 |
5 files changed, 30 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3767199..5760eec 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,15 @@ +2005-05-03 DJ Delorie <dj@redhat.com> + + * common.opt (fdiagnostics-show-option): No variable is needed. + * diagnostic.h (diagnostic_context): Add show_option_requested flag. + * diagnostic.c (diagnostic_initialize): Initialize show_option_requested. + (diagnostic_report_diagnostic): Test for enabled diagnostics here. + Save and restore original message format. Use flag in context + instead of global. + (warning): Don't test for enabled warnings here. + * opts.c (common_handle_option): Handle -fdiagnostics-show-option + here. + 2005-05-04 Kelley Cook <kcook@gcc.gnu.org> * config/m32r/xm-m32r.h: Don't define HOST_WORDS_BIG_ENDIAN. diff --git a/gcc/common.opt b/gcc/common.opt index 466077c..ab0129f 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -337,7 +337,7 @@ Common Joined RejectNegative -fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped diagnostics fdiagnostics-show-option -Common Var(diagnostics_show_options) +Common Amend appropriate diagnostic messages with the command line option that controls them. fdump- diff --git a/gcc/diagnostic.c b/gcc/diagnostic.c index b50fb14..e481332 100644 --- a/gcc/diagnostic.c +++ b/gcc/diagnostic.c @@ -102,6 +102,7 @@ diagnostic_initialize (diagnostic_context *context) memset (context->diagnostic_count, 0, sizeof context->diagnostic_count); context->issue_warnings_are_errors_message = true; context->warning_as_error_requested = false; + context->show_option_requested = false; context->abort_on_error = false; context->internal_error = NULL; diagnostic_starter (context) = default_diagnostic_starter; @@ -331,11 +332,17 @@ diagnostic_report_diagnostic (diagnostic_context *context, error_recursion (context); } + if (diagnostic->option_index + && ! option_enabled (diagnostic->option_index)) + return; + context->lock++; if (diagnostic_count_diagnostic (context, diagnostic)) { - if (diagnostics_show_options && diagnostic->option_index) + const char *saved_format_spec = diagnostic->message.format_spec; + + if (context->show_option_requested && diagnostic->option_index) diagnostic->message.format_spec = ACONCAT ((diagnostic->message.format_spec, " [", cl_options[diagnostic->option_index].opt_text, "]", NULL)); @@ -347,6 +354,7 @@ diagnostic_report_diagnostic (diagnostic_context *context, (*diagnostic_finalizer (context)) (context, diagnostic); pp_flush (context->printer); diagnostic_action_after_output (context, diagnostic); + diagnostic->message.format_spec = saved_format_spec; } context->lock--; @@ -424,9 +432,6 @@ warning (int opt, const char *msgid, ...) diagnostic_info diagnostic; va_list ap; - if (opt && ! option_enabled (opt)) - return; - va_start (ap, msgid); diagnostic_set_info (&diagnostic, msgid, &ap, input_location, DK_WARNING); diagnostic.option_index = opt; diff --git a/gcc/diagnostic.h b/gcc/diagnostic.h index 37cded711..5bbb135 100644 --- a/gcc/diagnostic.h +++ b/gcc/diagnostic.h @@ -73,6 +73,10 @@ struct diagnostic_context /* True if it has been requested that warnings be treated as errors. */ bool warning_as_error_requested; + /* True if we should print the command line option which controls + each diagnostic, if known. */ + bool show_option_requested; + /* True if we should raise a SIGABRT on errors. */ bool abort_on_error; @@ -818,6 +818,10 @@ common_handle_option (size_t scode, const char *arg, int value) return 0; break; + case OPT_fdiagnostics_show_option: + global_dc->show_option_requested = true; + break; + case OPT_fdump_: if (!dump_switch_p (arg)) return 0; |