5

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?

Aymanadou
  • 1,200
  • 1
  • 14
  • 36

2 Answers2

8

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

VGE
  • 4,171
  • 18
  • 17
  • @VGCE so what would the op do to correct the warning? What should go in the action? – Har Jul 02 '14 at 20:02
0

Use the union definition to type your given tokens from lex.

Aymanadou
  • 1,200
  • 1
  • 14
  • 36