bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] --warnings=no-XXX [RFC] --warnings categories


From: Di-an JAN
Subject: [PATCH] --warnings=no-XXX [RFC] --warnings categories
Date: Wed, 19 Nov 2008 18:06:10 -0800 (PST)

This patch implemented -Wno-XXX as already documented in the manual,
with -Wno-all = -Wnone (but without changing -Werror) and
-Wno-none = -Wall,error (not worth fixing).
As a side effect, no-XXX also works in --report and --trace.

Two more problems: the manual says -Wno-syntax (not implemented)
turns off ``useless'' warnings, and -Wnone only turn off -Wmidrule-values
not other warnings.  We need to categorize the existing warnings.
RFC below.

Patch tested with make check on Cygwin with one expected failure.

2008-11-19  Di-an Jan  <address@hidden>

        Implement no-XXX arguments for --warnings, --report, --trace.
        * src/getargs.c (flags_argmatch): Handles no-XXX.
        Fix typo in doxygen comment.

 src/getargs.c |   19 ++++++++++++++-----
 1 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/getargs.c b/src/getargs.c
index 2a0611b..d744b67 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, ",");
        }
     }

-----------------------------------------------------------------------

        --warnings/-W categories

-----------------------------------------------------------------------

(basic): Things that don't work as intended.  Should be on by default.
I don't have a good category name for these, but -Wnone would shut them up
(or not).

"symbol `%s' used more than once as a literal string"
"symbol `%s' given more than one literal string"
  I think these should be errors, since the first is ambiguous
  and the second we don't handle.

"conflicting outputs to file %s"

"%%expect-rr applies only to GLR parsers"
  Why not allow this for non-GLR parsers?  Can people rely on the POSIX
  rule that RR conflicts are resolved by choosing the earliest rule.

"%s affects only GLR parsers", "%dprec"
"%s affects only GLR parsers", "%merge"
"%s `%s' redefined", "%define variable"
[%s `%s' is not used], "%define"/"%code"

Might as well lump in other uncategorized warnings:

"line number overflow"
"column number overflow"

-----------------------------------------------------------------------

-Wsyntax: Things that should not be problems but may be a matter of style.
Perhaps part of the above, turned off only by -Wnone.
Should be on by default.

"stray `$'"
"stray `@'"
  Probably shouldn't warn.  It should be up to the compiler.
  In fact, Java code can have `@' (for annotations).

"stray `,' treated as white space"

"symbol %s redeclared"

We can also warn about extra/missing semicolons and adjacent actions.
Perhaps also -Wyacc POSIX nonportabilities that can be worked around
(e.g. %prec not at end of rule; not %locations).

-----------------------------------------------------------------------

-Wunused = -Wuseless
Should be on by default.

"nonterminal useless in grammar: %s"
"rule useless in grammar"
"rule useless in parser due to conflicts"

There are actually two kinds.  Some things are ``useless'' because they
cannot derive a finite sequence of tokens such as:
        start: | bad ;
        bad: '*' bad ;
I think these are always infinite loops and should be errors.
The message should say something about that too.  It's easy to type
        elements: elements | elements element ;

Useful to turn off while developing a grammar so it's easier to see other
messages.

-----------------------------------------------------------------------

-Wtypes
Should be on by default.

"type clash on default action: <%s> != <%s>"
"empty rule for typed nonterminal, and no action"

Useful to turn off while writing semantic actions so it's easier to see other
messages.

-----------------------------------------------------------------------

-Wmidrule-values

"unused value: $%d"
"unset value: $$"

-----------------------------------------------------------------------

-Wyacc

I'm working on that.

-----------------------------------------------------------------------




reply via email to

[Prev in Thread] Current Thread [Next in Thread]