mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-11 21:33:04 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ flags_argmatch (const char *option,
|
||||
args = strtok (args, ",");
|
||||
while (args)
|
||||
{
|
||||
int value = all;
|
||||
int value = 0;
|
||||
int *save_flags = flags;
|
||||
int no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
|
||||
int err = STRPREFIX_LIT ("error", args + no) ? 5 : 0;
|
||||
@@ -99,7 +99,12 @@ flags_argmatch (const char *option,
|
||||
|
||||
if (!value)
|
||||
{
|
||||
if (no)
|
||||
/* With a simpler 'if (no)' version, -Werror means -Werror=all
|
||||
(or rather, -Werror=no-none, but that syntax is invalid).
|
||||
The difference is:
|
||||
- Werror activates all errors, but not the warnings
|
||||
- Werror=all activates errors, and all warnings */
|
||||
if (no ? !err : err)
|
||||
*flags |= all;
|
||||
else
|
||||
*flags &= ~all;
|
||||
@@ -681,6 +686,8 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
warnings_flag |= Wyacc;
|
||||
errors_flag |= Wyacc;
|
||||
yacc_flag = true;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user