[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lint warnings from `bison -y' generated files
From: |
Akim Demaille |
Subject: |
Re: lint warnings from `bison -y' generated files |
Date: |
Wed, 05 Oct 2005 09:09:59 +0200 |
User-agent: |
Gnus/5.110004 (No Gnus v0.4) Emacs/21.4 (gnu/linux) |
>>> "Paul" == Paul Eggert <address@hidden> writes:
> OK, so it's impossible in general to shut off those messages with
> /*CONSTCOND*/. Then let's not bother to try.
You see me surprised! You and I are militants of killing the
warnings, so I do understand Nicolas' point, in particular in
generated code. This is somewhat inconsistent with your arguments
pro-alloca.
>> Fixing all lint warnings will be a real pain !
> Yes, at some point the cost exceeds the benefit.
Yep :(
> yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
> {
> - /* `Use' the arguments. */
> - (void) yy0;
> - (void) yy1;
> + /* Suppress unused-variable warnings. */
> + yy0 = yy0;
> + yy1 = yy1;
Doh... Not beautiful at all :( How about defining
YY_ATTRIBUTE_UNUSED and see adjust its definition depending on the
tool (I hate to say that...). This is also better documentation.
> Index: data/lalr1.cc
> ===================================================================
> RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
> retrieving revision 1.106
> diff -p -u -r1.106 lalr1.cc
> --- data/lalr1.cc 2 Oct 2005 20:41:42 -0000 1.106
> +++ data/lalr1.cc 5 Oct 2005 05:57:29 -0000
> @@ -411,12 +411,12 @@ void
> yy::]b4_parser_class_name[::yysymprint_ (int yytype,
> const semantic_type* yyvaluep, const
> location_type* yylocationp)
> {
> - /* Pacify ``unused variable'' warnings. */
> - (void) yyvaluep;
> - (void) yylocationp;
> /* Backward compatibility, but should be removed eventually. */
> std::ostream& cdebug_ = *yycdebug_;
> - (void) cdebug_;
> +
> + /* Suppress unused-variable warnings. */
> + if (false)
> + yysymprint_ (yytype + !&cdebug_, yyvaluep, yylocationp);
This is really hackish and obscure. This is also C++, for which we
have no evidence a Lint++ would be a problem. As a matter of fact I
just read a book by C++ gurus that promote just evaluating the
variable to shush the compiler (without the ugly C style cast to
void).
But again, YY_ATTRIBUTE_UNUSED could be used.
> *yycdebug_ << (yytype < yyntokens_ ? "token" : "nterm")
> << ' ' << yytname_[yytype] << " ("
> @@ -435,10 +435,9 @@ void
> yy::]b4_parser_class_name[::yydestruct_ (const char* yymsg,
> int yytype, semantic_type* yyvaluep,
> location_type* yylocationp)
> {
> - /* Pacify ``unused variable'' warnings. */
> - (void) yymsg;
> - (void) yyvaluep;
> - (void) yylocationp;
> + /* Suppress unused-variable warnings. */
> + if (false)
> + yydestruct_ (yymsg, yytype, yyvaluep, yylocationp);
> YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);