warning Bison compilation

Aymanadou picture Aymanadou · Sep 8, 2011 · Viewed 9.7k times · Source

am developping a compiler using flex/bison. I have this warning in my build output.

warning: type clash ('s' '') on default action

any help please?

Answer

VGE picture VGE · Dec 14, 2011

It seems to be related to your %token and %type declaration in your source. without the source line and the related token and type declaration it is difficult to help you.

If you specify an expr of type val and definer an ID token of type tptr

%{
#include "parser.h"
%}
%type <val> expr
%token <tptr> ID

If you write without any action bison will emit a warning

expr : ID;

warning: type clash ('tptr' 'val') on default action

Note that the bison level I am currently using print a slighty different message in this case.

foo.by:10.12:warning: type clash on default action : <tptr> != <val>

To fix this warning you need an explicit action:

expr : ID { $$ = some_conversion_code($1); }

http://www.gnu.org/s/bison/manual/bison.html#Token-Decl