Hi John, Le 28 janv. 2013 à 12:41, John P. Hartmann <jphartm...@gmail.com> a écrit :
> I have a fine grammar, but I get unset value warnings in droves when I add > empty %destructor declartions (the error token is not [yet] referenced). > > This applies to Bison 2.5 on Fedora 17 and also 2.4.1 on Fedora13. > > %union > { > struct instruction * inst; > struct expression * exp; > struct term term; > int kwd; > } > > /* > %destructor {} <inst> > %destructor {} <exp> > %destructor {} <term> > */ > %destructor {} <kwd> > > The offending rule: > > | PARSE parsehow parsecase parsewhat SEMICOLON > { > $$=GETINSTXP(@$, parse, $4); > } > > The messages: > > rexxy.y:401.19-404.19: warning: unused value: $2 > rexxy.y:401.19-404.19: warning: unused value: $3 > > It is true that $2 and $3 are not referenced in the action. In this > particular context they are valid, but have no effect. > > If I comment out the destructor, the grammar is processed without errors or > warnings. If you declared destructors for parsehow and parsecase, it is understood as "these symbols allocated memory that needs to be reclaimed before the symbol is destroyed". Bison can "see" that you are not using these symbols in the action, so you are certainly leaking them. The parser will _not_ reclaim them: %destructor is there for error recovery, not to reclaim the memory of rhs symbols in an action reduction. _______________________________________________ help-bison@gnu.org https://lists.gnu.org/mailman/listinfo/help-bison