bison-patches
[Top][All Lists]
Advanced

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

Re: too many warnings from Bison CVS for Pike


From: Joel E. Denny
Subject: Re: too many warnings from Bison CVS for Pike
Date: Mon, 30 Jan 2006 03:19:35 -0500 (EST)

On Sun, 29 Jan 2006, Paul Eggert wrote:

> If we enabled these warnings
> via an option I don't think people would object.

I was just looking back through that tangled `%destructor feedback' thread 
trying to remember how we arrived at the current implementation.  Frank 
Heckenbach actually suggested such a `global flag'.  I suggested that it 
wouldn't really be necessary since bison should only warn about unused 
semantic values with destructors.  He then suggested that any unused 
semantic value is strange enough to deserve a warning, and I agreed.  But 
then I argued against the global flag because I thought it would be too 
dangerous to let users choose to ignore the warnings.

Now that I look over your example grammars, it's clear to me that the 
warnings are sometimes too much.  But perhaps the solution is just to have 
two levels of warnings:

1. Vital warnings (usually related to memory allocation) that cannot be 
disabled by a global flag.  These can only be disabled by actually using 
the semantic values inside the actions.  There are three categories for 
this first level.  I haven't tested it myself, but I believe all are 
currently implemented:

a. If a non-midrule $n has a %destructor, bison warns if the action 
doesn't mention it since the action is responsible for freeing its memory.  
It doesn't matter if $n has a %type since, for example, $<TYPE>n might be 
used.  The %destructor is the key here.

b. If a non-midrule $$ has a %destructor, bison warns if the action 
doesn't mention it since the action is responsible for assigning the 
memory that a %destructor may later try to free.  Like $n, it doesn't 
matter if $$ has a %type.

c. For a $$ or $n that corresponds to a mid-rule action, bison warns if 
one is mentioned but not the other... because that just seems bizarre and 
likely a mistake.  It's bizarre regardless of whether there's a 
%destructor for the used type.  %type is impossible of course.

2. Non-vital warnings that can thus be disabled by a single global flag.  
Two categories:

a. Unused, non-midrule, typed $n.
b. Unused, non-midrule, typed $$.

In symbol_should_be_used, I believe the implementation would be something 
like this:

  return ((s->sym->type_name && !global_flag)
          || s->sym->destructor
          || (s->midrule && s->midrule->used));

Notice the polarity of global_flag: the user has to set the flag to turn 
*off* the %type related warnings.  Otherwise, I doubt most users will ever 
notice this feature.

For warnings of either level, there might be cases where the author is 
absolutely sure it's OK to ignore a value.  Thus, there should be some 
construct to declare the value as used.  We debated what that construct 
should be at length: YYUSE, YYBISON_USE, USE, YYUSE_VAL, YYUCK, $<>n

> This particular warning is worse than questionable: it's 100% bogus.
> But it's caused by a separate and longstanding bug in Bison, having to
> do with two adjacent actions.  I didn't know about that bug, but I'm
> about to install a fix for it.

I believe Akim also mentioned this bug back when he was working on the 
midrule warnings.

Joel




reply via email to

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