[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lint warnings from `bison -y' generated files
From: |
Nicolas Joly |
Subject: |
Re: lint warnings from `bison -y' generated files |
Date: |
Wed, 5 Oct 2005 00:33:35 +0200 |
User-agent: |
Mutt/1.5.8i |
On Tue, Oct 04, 2005 at 12:43:37PM -0700, Paul Eggert wrote:
> Nicolas Joly <address@hidden> writes:
>
> > - (void)yyvaluepn; ... line 842.
>
> Thanks for reporting the problem. Would substituting "yyvaluepn =
> yyvaluepn;" for "(void) yyvaluepn;" suffice to turn off that warning?
Yes. Warning gone.
NB: I made a typo, it was `yyvaluep' and not `yyvaluepn'.
> > - do {} while (0) ... lines 1023/1024.
> > - if (0) {} ... line 1358.
> >
> > Except for the fisrt one, it should be easy to fix them by adding a
> > `/*CONSTCOND*/' lint directive.
>
> I dunno about this one. Bison uses constant operands in a lot of
> places in conditional contexts; it relies on the compiler optimizing
> away the test and the unused branch. In some cases Bison itself
> doesn't know whether the expression is conditional (that is determined
> partly by the context in which the parser is compiled), so we can't
> just blithely insert /*CONSTCOND*/ all over the place. Also, let's
> face it, /*CONSTCOND*/ is ugly.
I see your arguments here, and mostly agree. I was only trying to
reduce the warnings number for code that i do not produce myself (96
for bison in 16 parsers and 37 for flex in 16 analyzers), which hide
my potential mistakes ;-)
> Can't you just ask 'lint' to be quiet about this particular problem
> instead? Complaining about constants used in conditional contexts
> might have made sense back in the 1970s, but today it seems
> counterproductive -- in some sense you're asking modern compilers to
> please not optimize so much!
It seems that lint programs have no standards, just common practices
... Some implementation can suppress this warning with command line
flags (NetBSD: -X161, Tru64: -wC), some don't (Solaris). Even
`/*CONSTCOND*/' does not seem to be understood by Tru64 lint.
Fixing all lint warnings will be a real pain !
Thanks.
--
Nicolas Joly
Biological Software and Databanks.
Institut Pasteur, Paris.