errors: change output, and improve -y coherence

The prefix of warnings treated as errors is now "error: ". Also, their
suffix now reflects the changes in the Werror option format.

An output for -Werror=other used to be:
  bison: warnings being treated as errors
  input.y:1.1: warning: stray ',' treated as white space [-Wother]

It is now:
  bison: warnings being treated as errors
  input.y:1.1: error: stray ',' treated as white space [-Werror=other]

The line "warnings being treated as errors" no longer adds any info,
it will be removed in a forthcoming change.

* NEWS: Add entry "Enhancement of the -Werror"
* doc/bison.texi: Move the warnings-as-error to a new bullet.
* src/complain.c (complains): Refactor, change the prefix of warnings
that are treated as errors.
(warnings_print_categories): Support for [-Werror=CATEGORY] display
* src/getargc.c (getargs): -y implies -Werror=yacc
* tests/input.at: Update expected --yacc output for coherence.

Signed-off-by: Akim Demaille <akim@lrde.epita.fr>
This commit is contained in:
Akim Demaille
2012-09-27 12:19:09 +02:00
parent 9503b0a4a8
commit 1048a1c901
6 changed files with 100 additions and 41 deletions

View File

@@ -57,7 +57,9 @@ warnings_print_categories (warnings warn_flags)
for (i = 0; i < ARRAY_CARDINALITY (warn_names); ++i)
if (warn_flags & 1 << i)
{
fprintf (stderr, "%s-W%s", any ? ", " : " [", warn_names[i]);
bool err = warn_flags & errors_flag;
fprintf (stderr, "%s-W", any ? ", " : " [");
fprintf (stderr, "%s%s", err ? "error=" : "" , warn_names[i]);
any = true;
}
if (any)
@@ -121,39 +123,22 @@ error_message (const location *loc, warnings flags, const char *prefix,
static inline void
complains (const location *loc, warnings flags, const char *message,
va_list args)
{
if (flags & complaint)
if (flags & fatal)
{
error_message (loc, complaint,
indent_ptr && *indent_ptr ? NULL : _("error"),
message, args);
complaint_issued = true;
error_message (loc, fatal, _("fatal error"), message, args);
exit (EXIT_FAILURE);
}
else if (flags & fatal)
{
error_message (loc, fatal, _("fatal error"), message, args);
exit (EXIT_FAILURE);
}
else if (flags & Wyacc)
{
if (yacc_flag)
{
error_message (loc, flags, NULL, message, args);
complaint_issued = true;
}
else if (warnings_flag & Wyacc)
{
set_warning_issued (Wyacc);
error_message (loc, flags,
indent_ptr && *indent_ptr ? NULL : _("warning"),
message, args);
}
}
else if (warnings_flag & flags)
else if (flags & (complaint | warnings_flag))
{
const char* prefix =
flags & (errors_flag | complaint) ? _("error") : _("warning");
if (flags & complaint)
complaint_issued = true;
set_warning_issued (flags);
error_message (loc, flags,
indent_ptr && *indent_ptr ? NULL : _("warning"),
indent_ptr && *indent_ptr ? NULL : prefix,
message, args);
}
}