[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lint warnings from `bison -y' generated files
From: |
Paul Eggert |
Subject: |
Re: lint warnings from `bison -y' generated files |
Date: |
Tue, 04 Oct 2005 23:21:05 -0700 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.4 (gnu/linux) |
Nicolas Joly <address@hidden> writes:
> It seems that lint programs have no standards, just common practices
Yes, that's part of the problem.
> ... Some implementation can suppress this warning with command line
> flags (NetBSD: -X161, Tru64: -wC), some don't (Solaris).
With Solaris you can suppress this bogus warning as follows:
lint -erroff=E_CONSTANT_CONDITION foo.c
See <http://docs.sun.com/source/819-0494/lint.html>.
> Even `/*CONSTCOND*/' does not seem to be understood by Tru64 lint.
OK, so it's impossible in general to shut off those messages with
/*CONSTCOND*/. Then let's not bother to try. People who want to use
lint should rely on lint flags, or use 'sed' to remove the bogus
messages if lint doesn't let you shut them off.
> Fixing all lint warnings will be a real pain !
Yes, at some point the cost exceeds the benefit.
I installed this patch to fix the problems with casts to void:
2005-10-04 Paul Eggert <address@hidden>
* data/glr.c (yyuserMerge, yyreportAmbiguity, yyreportSyntaxError):
Use assignments rather than casts-to-void to suppress
unused-variable warnings. This pacifies 'lint'.
* data/lalr1.cc (yysymprint_, yydestruct_): Use a call to suppress
unused-variable warnings.
Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.126
diff -p -u -r1.126 glr.c
--- data/glr.c 2 Oct 2005 21:24:11 -0000 1.126
+++ data/glr.c 5 Oct 2005 05:57:29 -0000
@@ -889,9 +889,9 @@ b4_syncline(address@hidden@], address@hidden@])
static void
yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
{
- /* `Use' the arguments. */
- (void) yy0;
- (void) yy1;
+ /* Suppress unused-variable warnings. */
+ yy0 = yy0;
+ yy1 = yy1;
switch (yyn)
{
@@ -1633,9 +1633,9 @@ static void
yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
yyGLRStack* yystack]b4_pure_formals[)
{
- /* `Unused' warnings. */
- (void) yyx0;
- (void) yyx1;
+ /* Suppress unused-variable warnings. */
+ yyx0 = yyx0;
+ yyx1 = yyx1;
#if YYDEBUG
YYFPUTS ("Ambiguity detected.\nOption 1,\n", stderr);
@@ -1847,9 +1847,9 @@ static void
yyreportSyntaxError (yyGLRStack* yystack,
YYSTYPE* yylvalp, YYLTYPE* yyllocp]b4_user_formals[)
{
- /* `Unused' warnings. */
- (void) yylvalp;
- (void) yyllocp;
+ /* Suppress unused-variable warnings. */
+ yylvalp = yylvalp;
+ yyllocp = yyllocp;
if (yystack->yyerrState == 0)
{
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);
*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);