This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: warning message control: jumbo patch so far
- From: DJ Delorie <dj at redhat dot com>
- To: gdr at integrable-solutions dot net
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 3 May 2005 17:22:26 -0400
- Subject: Re: warning message control: jumbo patch so far
- References: <200504230001.j3N01RR8016620@greed.delorie.com><4269966E.1020708@codesourcery.com><200504230039.j3N0dWvp017120@greed.delorie.com><4269A6B7.7070402@codesourcery.com><200504232138.j3NLcscP001625@greed.delorie.com><200504252153.j3PLr5X9026266@greed.delorie.com><200504292255.j3TMtSFY013487@greed.delorie.com><m3k6mkjtai.fsf@uniton.integrable-solutions.net><200505022127.j42LRpgL001732@greed.delorie.com> <m34qdkahyg.fsf@uniton.integrable-solutions.net>
> * that adds a field "show_options" to diagnostic_context, that
> consistently play the role of diagnostic_show_options;
> * that has this . . .
Is this what you meant?
2005-05-02 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.
Index: common.opt
===================================================================
RCS file: /cvs/gcc/gcc/gcc/common.opt,v
retrieving revision 1.69
diff -p -U3 -r1.69 common.opt
--- common.opt 3 May 2005 17:55:27 -0000 1.69
+++ common.opt 3 May 2005 21:22:06 -0000
@@ -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-
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.c,v
retrieving revision 1.150
diff -p -U3 -r1.150 diagnostic.c
--- diagnostic.c 3 May 2005 17:55:28 -0000 1.150
+++ diagnostic.c 3 May 2005 21:22:06 -0000
@@ -102,6 +102,7 @@ diagnostic_initialize (diagnostic_contex
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
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
(*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;
Index: diagnostic.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.h,v
retrieving revision 1.73
diff -p -U3 -r1.73 diagnostic.h
--- diagnostic.h 3 May 2005 17:55:31 -0000 1.73
+++ diagnostic.h 3 May 2005 21:22:06 -0000
@@ -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;
Index: opts.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/opts.c,v
retrieving revision 1.106
diff -p -U3 -r1.106 opts.c
--- opts.c 3 May 2005 17:55:37 -0000 1.106
+++ opts.c 3 May 2005 21:22:06 -0000
@@ -818,6 +818,10 @@ common_handle_option (size_t scode, cons
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;