foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
$ bison -Werror foo.y
- bison: warnings being treated as errors
- foo.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
- foo.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
+ foo.y: error: 1 shift/reduce conflict [-Werror=conflicts-sr]
+ foo.y: error: 2 reduce/reduce conflicts [-Werror=conflicts-rr]
When %expect or %expect-rr is used, such as with bar.y:
New one:
$ bison bar.y
- bar.y: shift/reduce conflicts: 1 found, 0 expected
- bar.y: reduce/reduce conflicts: 2 found, 0 expected
+ bar.y: error: shift/reduce conflicts: 1 found, 0 expected
+ bar.y: error: reduce/reduce conflicts: 2 found, 0 expected
** Additional yylex/yyparse arguments
warnings warnings_flag =
Wconflicts_sr | Wconflicts_rr | Wdeprecated | Wother;
+warnings errors_flag;
+
bool complaint_issued;
static unsigned *indent_ptr = 0;
}
else if (warnings_flag & Wyacc)
{
- set_warning_issued ();
+ set_warning_issued (Wyacc);
error_message (loc, flags,
indent_ptr && *indent_ptr ? NULL : _("warning"),
message, args);
}
else if (warnings_flag & flags)
{
- set_warning_issued ();
+ set_warning_issued (flags);
error_message (loc, flags,
indent_ptr && *indent_ptr ? NULL : _("warning"),
message, args);
`--------------------------------*/
void
-set_warning_issued (void)
+set_warning_issued (warnings warning)
{
static bool warning_issued = false;
- if (!warning_issued && (warnings_flag & Werror))
+ if (!warning_issued && (warning & warnings_flag & errors_flag))
{
fprintf (stderr, "%s: warnings being treated as errors\n", program_name);
complaint_issued = true;
Wdeprecated = 1 << 4, /**< Obsolete constructs. */
Wother = 1 << 5, /**< All other warnings. */
- Werror = 1 << 10, /**< Warnings are treated as errors. */
+ Werror = 1 << 10, /** This bit is no longer used. */
+
complaint = 1 << 11, /**< All complaints. */
fatal = 1 << 12, /**< All fatal errors. */
silent = 1 << 13, /**< Do not display the warning type. */
- Wall = ~Werror /**< All above warnings. */
+
+ /**< All above warnings. */
+ Wall = ~complaint & ~fatal & ~silent
} warnings;
/** What warnings are issued. */
extern warnings warnings_flag;
+/** What warnings are made errors. */
+extern warnings errors_flag;
+
/** Display a "[-Wyacc]" like message on stderr. */
void warnings_print_categories (warnings warn_flags);
only for the sake of Yacc-compatible conflict reports in conflicts.c.
All other warnings should be implemented in complain.c and should use
the normal warning format. */
-void set_warning_issued (void);
+void set_warning_issued (warnings warning);
/** Make a complaint, but don't specify any location. */
void complain (warnings flags, char const *message, ...)
args = strtok (args, ",");
while (args)
{
+ int value = all;
+ int *save_flags = flags;
int no = STRPREFIX_LIT ("no-", args) ? 3 : 0;
- int value = XARGMATCH (option, args + no, keys, values);
- if (value == 0)
+ int err = STRPREFIX_LIT ("error", args + no) ? 5 : 0;
+
+ if (err)
+ flags = &errors_flag;
+ if (!err || args[no + err++] != '\0')
+ value = XARGMATCH (option, args + no + err, keys, values);
+
+ if (!value)
{
if (no)
*flags |= all;
if (no)
*flags &= ~value;
else
- *flags |= value;
+ {
+ if (err)
+ warnings_flag |= value;
+ *flags |= value;
+ }
}
+ flags = save_flags;
args = strtok (NULL, ",");
}
}
fputs (_("\
Warning categories include:\n\
- `midrule-values' unset or unused midrule values\n\
- `yacc' incompatibilities with POSIX Yacc\n\
- `conflicts-sr' S/R conflicts (enabled by default)\n\
- `conflicts-rr' R/R conflicts (enabled by default)\n\
- `deprecated' obsolete constructs\n\
- `other' all other warnings (enabled by default)\n\
- `all' all the warnings\n\
- `no-CATEGORY' turn off warnings in CATEGORY\n\
- `none' turn off all the warnings\n\
- `error' treat warnings as errors\n\
+ `midrule-values' unset or unused midrule values\n\
+ `yacc' incompatibilities with POSIX Yacc\n\
+ `conflicts-sr' S/R conflicts (enabled by default)\n\
+ `conflicts-rr' R/R conflicts (enabled by default)\n\
+ `deprecated' obsolete constructs\n\
+ `other' all other warnings (enabled by default)\n\
+ `all' all the warnings\n\
+ `no-CATEGORY' turn off warnings in CATEGORY\n\
+ `none' turn off all the warnings\n\
+ `error[=CATEGORY]' treat warnings as errors\n\
"), stdout);
putc ('\n', stdout);