Finish implementing --warnings=error, which should not be implied by

--warnings=all (or by its synonyms -W and --warnings without
subarguments).
* src/complain.c (set_warning_issued): New function to report that
warnings are being treated as errors and to record an error if so.
Invoke...
(warn_at, warn): ... here.
* src/getargs.c (warnings_args, warnings_types): Reorder so that
"error - warnings are errors" does not appear above "all - all of the
above".
(getargs): For -W and --warnings without subarguments, don't let
FLAGS_ARGMATCH set warnings_error in warnings_flag.
* src/getargs.h (enum warnings): Unset warnings_error in warnings_all.
This commit is contained in:
Joel E. Denny
2006-11-01 01:47:44 +00:00
parent ba7560e26b
commit 89eb3c7653
4 changed files with 39 additions and 5 deletions

View File

@@ -28,6 +28,7 @@
#include "complain.h"
#include "files.h"
#include "getargs.h"
/* The calling program should define program_name and set it to the
name of the executing program. */
@@ -79,15 +80,29 @@ error_message (location *loc,
| Report a warning, and proceed. |
`--------------------------------*/
static void
set_warning_issued (void)
{
static bool warning_issued = false;
if (!warning_issued && (warnings_flag & warnings_error))
{
fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
complaint_issued = true;
}
warning_issued = true;
}
void
warn_at (location loc, const char *message, ...)
{
set_warning_issued ();
ERROR_MESSAGE (&loc, _("warning"), message);
}
void
warn (const char *message, ...)
{
set_warning_issued ();
ERROR_MESSAGE (NULL, _("warning"), message);
}