This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: warning message control: check for enabled warnings
> I suspect that this breaks i18n? We havn't yet looked up the
> translated version of msgid...
This version moves it after the lookup.
Index: diagnostic.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/diagnostic.c,v
retrieving revision 1.149
diff -p -U3 -r1.149 diagnostic.c
--- diagnostic.c 23 Apr 2005 21:27:38 -0000 1.149
+++ diagnostic.c 29 Apr 2005 23:10:21 -0000
@@ -40,6 +40,7 @@ Software Foundation, 59 Temple Place - S
#include "diagnostic.h"
#include "langhooks.h"
#include "langhooks-def.h"
+#include "opts.h"
/* Prototypes. */
@@ -412,13 +413,22 @@ inform (const char *msgid, ...)
/* A warning. Use this for code which is correct according to the
relevant language specification but is likely to be buggy anyway. */
void
-warning (int opt ATTRIBUTE_UNUSED, const char *msgid, ...)
+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);
+
+ if (warn_show_options && opt)
+ diagnostic.message.format_spec
+ = ACONCAT ((diagnostic.message.format_spec,
+ " [", cl_options[opt].opt_text, "]", 0));
+
report_diagnostic (&diagnostic);
va_end (ap);
}