[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug report . Bison 1.875
From: |
Laurent D. Michel |
Subject: |
Bug report . Bison 1.875 |
Date: |
24 Jan 2003 09:26:56 -0500 |
Summary:
The generated code does not compile.
Compiler used gcc-2.95.4
Environment Debian/sid and Debian/woody
The grammar.y file is intended to generate code for a C++ parser. The parser is tagged pure.
Here is the output I get when compiling:
compiling C grammar.tab.c
/tmp/tmpParserldm: In function `int yyparse(LocParser *)':
/tmp/tmpParserldm:4796: ANSI C++ forbids declaration `yylerrsp' with no type
/tmp/tmpParserldm:4796: conflicting types for `int yylerrsp'
/tmp/tmpParserldm:2753: previous declaration as `struct YYLTYPE * yylerrsp'
/tmp/tmpParserldm:4796: initialization to `int' from `YYLTYPE *' lacks a cast
/tmp/tmpParserldm:4797: invalid type argument of `unary *'
/tmp/tmpParserldm:4839: invalid operands `int' and `YYLTYPE *' to binary `operator -'
/tmp/tmpParserldm:4839: invalid operands `int' and `YYLTYPE *' to binary `operator -'
/tmp/tmpParserldm:4788: warning: label `yyerrlab1' defined but not used
And here is the compilation command line (around line 4796)
g++-2.95 -c -Wall -fPIC -g -Woverloaded-virtual -I../include -I../data -I../localizer -I../runtime grammar.tab.c
The code fragment extracted from the c file is:
yyerrlab1:
/* Suppress GCC warning that yyerrlab1 is unused when no action
invokes YYERROR. */
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
__attribute__ ((__unused__))
#endif
yylerrsp = yylsp;
*++yylerrsp = yyloc;
goto yyerrlab2;
If I remove the #if defined(....) that precedes the yylerrsp = yylsp everything works as expected.
I attach the grammar.tab.c file to this email for reference.
Also, I would like to suggest a feature....
I use bison to generate a parser that is used from C++. As such, the yyparse function takes an
argument which happens to be a pointer to the parser object. So far, the yyparse has the prototype
yyparse(void *YYPARSE_PARAM)
What I usually do is used sed to replace the void in the signature by the type of the parser object (LocParser in this case). It would be nice to have that configurable with a macro such as
yyparse(YYPARSE_PARAM_TYPE *YYPARSE_PARAM)
to avoid this sed step.
In any case, many thanks for your help,
Sincerely,
grammar.tab.c
Description: Text Data
grammar.tab.h
Description: Text Data
- Bug report . Bison 1.875,
Laurent D. Michel <=