warnings: fix early exit of warnings treated as errors

Treating warnings as errors caused Bison to exit earlier than needed, making it
hide warnings that would have been printed had -Werror not been set.

Also, fix a bug that caused some context information of errors to not be
shown.

* src/complain.c (complaint_issued): Rename as...
(complaint_status): This, and change its type from boolean to
* src/complain.h (err_status): This, new enumeration.
* src/main.c (main): Adjust (only finish early if an actual complaint was
risen, not a mere warning treated an error).
* src/reader.c: Adjust.
This commit is contained in:
Theophile Ranquet
2012-10-26 18:12:53 +00:00
parent 8f6bbe0c10
commit 697a8022c6
4 changed files with 22 additions and 8 deletions

View File

@@ -34,7 +34,7 @@ warnings warnings_flag =
warnings errors_flag;
bool complaint_issued;
err_status complaint_status = status_none;
static unsigned *indent_ptr = 0;
void
@@ -129,8 +129,11 @@ complains (const location *loc, warnings flags, const char *message,
: flags & (errors_flag | complaint) ? _("error")
: _("warning");
complaint_issued |= flags & (complaint | errors_flag);
if (flags & (warnings_flag | silent | fatal | complaint))
if ((flags & complaint) && complaint_status < status_complaint)
complaint_status = status_complaint;
else if ((flags & (warnings_flag & errors_flag)) && ! complaint_status)
complaint_status = status_warning_as_error;
if (flags & (warnings_flag | fatal | complaint))
error_message (loc, flags, prefix, message, args);
if (flags & fatal)
exit (EXIT_FAILURE);