On Wed, 4 Aug 2010, Joel E. Denny wrote: > Regardless of which functionality we pick for -Wnone, it probably should > not affect -Werror. Currently, it disables it. Even if we decide that > -Wnone should disable all warnings, it still should not affect -Werror in > the following case: > > bison -Werror -Wnone -Wyacc parser.y > > That is, POSIX Yacc warnings would be the only warnings and would be > treated as errors.
To put that another way, -Wall doesn't enable -Werror, so -Wnone shouldn't disable -Werror. I'd like to fix that on branch-2.5 and master. However, I first need to cherry pick a related patch from master to branch-2.5 and document that patch in NEWS. The whole patch series appears below. Any objections? >From 20cc714980c65f0035ae8dc60a562d6f86530af1 Mon Sep 17 00:00:00 2001 From: Di-an Jan <[email protected]> Date: Fri, 21 Nov 2008 13:09:16 -0800 Subject: [PATCH 1/3] Implement no-XXX arguments for --warnings, --report, --trace. * src/getargs.c (flags_argmatch): Handles no-XXX. Fix typo in doxygen comment. (cherry picked from commit 4182a0a18681fe4808f474441d62c5d2489e24e4) --- ChangeLog | 6 ++++++ src/getargs.c | 19 ++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 53dfb15..97c0906 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-11-21 Di-an Jan <[email protected]> + + Implement no-XXX arguments for --warnings, --report, --trace. + * src/getargs.c (flags_argmatch): Handles no-XXX. + Fix typo in doxygen comment. + 2011-03-20 Joel E. Denny <[email protected]> doc: fix confusing citation of LAC publication. diff --git a/src/getargs.c b/src/getargs.c index 2408550..d65cfc0 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -87,10 +87,12 @@ char *program_name; * \param keys array of valid subarguments. * \param values array of corresponding (int) values. * \param flags the flags to update - * \param args colon separated list of effective subarguments to decode. + * \param args comma separated list of effective subarguments to decode. * If 0, then activate all the flags. * - * The special value 0 resets the flags to 0. + * If VALUE != 0 then KEY sets flags and no-KEY clears them. + * If VALUE == 0 then KEY clears all flags and no-KEY sets all flags. + * Thus no-none = all and no-all = none. */ static void flags_argmatch (const char *option, @@ -102,11 +104,18 @@ flags_argmatch (const char *option, args = strtok (args, ","); while (args) { - int value = XARGMATCH (option, args, keys, values); + int no = strncmp (args, "no-", 3) == 0 ? 3 : 0; + int value = XARGMATCH (option, args + no, keys, values); if (value == 0) - *flags = 0; + if (no) + *flags = ~0; + else + *flags = 0; else - *flags |= value; + if (no) + *flags &= ~value; + else + *flags |= value; args = strtok (NULL, ","); } } -- 1.7.0.4 >From 248dba53cb3a33b6cea83050263080f6f000fbfe Mon Sep 17 00:00:00 2001 From: Joel E. Denny <[email protected]> Date: Sun, 27 Mar 2011 15:46:29 -0400 Subject: [PATCH 2/3] * NEWS (2.5): Document fix for -Wno-KEY. --- ChangeLog | 4 ++++ NEWS | 9 +++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97c0906..07b1149 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2011-03-27 Joel E. Denny <[email protected]> + + * NEWS (2.5): Document fix for -Wno-CATEGORY. + 2008-11-21 Di-an Jan <[email protected]> Implement no-XXX arguments for --warnings, --report, --trace. diff --git a/NEWS b/NEWS index 423cd7e..b866483 100644 --- a/NEWS +++ b/NEWS @@ -300,6 +300,15 @@ Bison News *** Parser traces now print the top element of the stack. +** -W/--warnings fixes: + +*** Bison now properly recognizes the "no-" versions of categories: + + For example, given the following command line, Bison now enables all + warnings except warnings for incompatibilities with POSIX Yacc: + + bison -Wall,no-yacc gram.y + * Changes in version 2.4.3 (2010-08-05): ** Bison now obeys -Werror and --warnings=error for warnings about -- 1.7.0.4 >From 310ebcafe2cbf039e3c0c580bfc0c9bb46a4c383 Mon Sep 17 00:00:00 2001 From: Joel E. Denny <[email protected]> Date: Sun, 27 Mar 2011 15:39:25 -0400 Subject: [PATCH 3/3] Don't let -Wnone disable -Werror. Discussed at <http://lists.gnu.org/archive/html/bison-patches/2010-08/msg00009.html>. * NEWS (2.5): Document. * src/getargs.c (flags_argmatch): Accept a new argument that specifies what flags "all" and thus "none" affect. (FLAGS_ARGMATCH): Update flags_argmatch invocation. * tests/input.at (-Werror is not affected by -Wnone and -Wall): New test group. --- ChangeLog | 12 ++++++++++++ NEWS | 7 +++++++ src/getargs.c | 27 ++++++++++++++------------- tests/input.at | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 07b1149..4eb5ebd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ 2011-03-27 Joel E. Denny <[email protected]> + Don't let -Wnone disable -Werror. + Discussed at + <http://lists.gnu.org/archive/html/bison-patches/2010-08/msg00009.html>. + * NEWS (2.5): Document. + * src/getargs.c (flags_argmatch): Accept a new argument that + specifies what flags "all" and thus "none" affect. + (FLAGS_ARGMATCH): Update flags_argmatch invocation. + * tests/input.at (-Werror is not affected by -Wnone and -Wall): + New test group. + +2011-03-27 Joel E. Denny <[email protected]> + * NEWS (2.5): Document fix for -Wno-CATEGORY. 2008-11-21 Di-an Jan <[email protected]> diff --git a/NEWS b/NEWS index b866483..243ada5 100644 --- a/NEWS +++ b/NEWS @@ -309,6 +309,13 @@ Bison News bison -Wall,no-yacc gram.y +*** The "none" category no longer disables a preceding "error": + + For example, for the following command line, Bison now reports + errors instead of warnings for incompatibilities with POSIX Yacc: + + bison -Werror,none,yacc gram.y + * Changes in version 2.4.3 (2010-08-05): ** Bison now obeys -Werror and --warnings=error for warnings about diff --git a/src/getargs.c b/src/getargs.c index d65cfc0..c558322 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -86,18 +86,19 @@ char *program_name; * \param option option being decoded. * \param keys array of valid subarguments. * \param values array of corresponding (int) values. + * \param all the all value. * \param flags the flags to update * \param args comma separated list of effective subarguments to decode. * If 0, then activate all the flags. * * If VALUE != 0 then KEY sets flags and no-KEY clears them. - * If VALUE == 0 then KEY clears all flags and no-KEY sets all flags. - * Thus no-none = all and no-all = none. + * If VALUE == 0 then KEY clears all flags from \c all and no-KEY sets all + * flags from \c all. Thus no-none = all and no-all = none. */ static void flags_argmatch (const char *option, const char * const keys[], const int values[], - int *flags, char *args) + int all, int *flags, char *args) { if (args) { @@ -106,21 +107,23 @@ flags_argmatch (const char *option, { int no = strncmp (args, "no-", 3) == 0 ? 3 : 0; int value = XARGMATCH (option, args + no, keys, values); - if (value == 0) + if (value == 0) { if (no) - *flags = ~0; + *flags |= all; else - *flags = 0; - else + *flags &= ~all; + } + else { if (no) *flags &= ~value; else *flags |= value; + } args = strtok (NULL, ","); } } else - *flags = ~0; + *flags |= all; } /** Decode a set of sub arguments. @@ -130,11 +133,12 @@ flags_argmatch (const char *option, * * \arg FlagName_args the list of keys. * \arg FlagName_types the list of values. + * \arg FlagName_all the all value. * \arg FlagName_flag the flag to update. */ #define FLAGS_ARGMATCH(FlagName, Args) \ flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \ - &FlagName ## _flag, Args) + FlagName ## _all, &FlagName ## _flag, Args) /*----------------------. @@ -579,10 +583,7 @@ getargs (int argc, char *argv[]) exit (EXIT_SUCCESS); case 'W': - if (optarg) - FLAGS_ARGMATCH (warnings, optarg); - else - warnings_flag |= warnings_all; + FLAGS_ARGMATCH (warnings, optarg); break; case 'b': diff --git a/tests/input.at b/tests/input.at index 9acd544..c8e28be 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1308,3 +1308,36 @@ AT_BISON_CHECK([[-Dparse.lac.memory-trace=full input.y]], ]]) AT_CLEANUP + +## --------------------------------------------- ## +## -Werror is not affected by -Wnone and -Wall. ## +## --------------------------------------------- ## + +AT_SETUP([[-Werror is not affected by -Wnone and -Wall]]) + +AT_DATA([[input.y]], +[[%% +foo-bar: ; +]]) + +# -Werror is not enabled by -Wall or equivalent. +AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]], +[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +]]) +AT_BISON_CHECK([[-W input.y]], [[0]], [[]], +[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +]]) +AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]], +[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +]]) + +# -Werror is not disabled by -Wnone or equivalent. +AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]]) +AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]], +[[bison: warnings being treated as errors +input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +]]) +[mv stderr experr] +AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]]) + +AT_CLEANUP -- 1.7.0.4
