help-bison
[Top][All Lists]
Advanced

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

Re: warning: unused value: $3


From: Joel E. Denny
Subject: Re: warning: unused value: $3
Date: Wed, 25 Oct 2006 20:27:37 -0400 (EDT)

On Wed, 25 Oct 2006 address@hidden wrote:

> using bison version 2.2.
> Message from bison:
> pl1-parser.y:873.17-63: warning: unused value: $3
> 
> This warning I find a bit confusing...

When we discussed adding this warning, we agreed that it's usually a 
mistake if the user sets $$ for a mid-rule but does not reference its $n 
in one of the semantic actions of the same rule.  We thought that cases 
where it's intentional (such as yours) are rare, and thus we thought that 
it is best for the user to declare that he omitted the $n intentionally.  
This is for Bison's sake as well as for the sake of other programmers who 
will read the grammar file.

For now, we usually declare this intentional omission using a preprocessor 
macro.  You could define it as:

  #define USE(VALUE) /*empty*/

> Line 873 contains: |  procoptionlist ',' {$$=$1;} procoption {$$=$1;}
> $3 refers to the embedded action after the comma.

In the last semantic action above, write:

  USE($3)

> My grammar set a number of attributes in an allocated structure using $0 to 
> reference the structure on the stack. The full rules are as follow

How frequently do you do this in your grammar?  In other words, how 
painful will it be to add the USE macro invocation to all those rules?




reply via email to

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