Menu

#13 byaccj generates C code which produces warnings on compilation

v1.x
open
nobody
None
5
2015-09-24
2015-09-24
Norman Gray
No

byaccj generates C code which produces warnings on compilation. See below. These can all be fixed rather trivially, I think.

If one builds with a warnings-are-errors flag (as I tend to do) then this will break a build and require special handling).

This is presumably a bug upstream of byaccj. Of course, byaccj is targeted at producing Java code rather than C, but in one project I am generating both C and Java, and it's convenient to use one yacc-a-like for both.

% /Data/tools/byaccj-1.15/bin/byaccj src/stripat-expression.y && mv y.tab.c build/stripat-expression.c
% cc -g -O2 -Wall -c -o build/stripat-expression.o -g build/stripat-expression.c 
src/stripat-expression.y:87:9: warning: implicit declaration of function 'yyparse' is
      invalid in C99 [-Wimplicit-function-declaration]
    if (yyparse()) {
        ^
y.tab.c:305:13: warning: using the result of an assignment as a condition without
      parentheses [-Wparentheses]
    if (yyn = yydefred[yystate]) goto yyreduce;
        ~~~~^~~~~~~~~~~~~~~~~~~
y.tab.c:305:13: note: place parentheses around the assignment to silence this warning
    if (yyn = yydefred[yystate]) goto yyreduce;
            ^
        (                      )
y.tab.c:305:13: note: use '==' to turn this assignment into an equality comparison
    if (yyn = yydefred[yystate]) goto yyreduce;
            ^
            ==
y.tab.c:353:1: warning: unused label 'yyerrlab' [-Wunused-label]
yyerrlab:
^~~~~~~~~
y.tab.c:348:1: warning: unused label 'yynewerror' [-Wunused-label]
yynewerror:
^~~~~~~~~~~
build/stripat-expression.c:2:13: warning: unused variable 'yysccsid' [-Wunused-variable]
static char yysccsid[] = "@(#)yaccpar   1.8 (Berkeley) 01/20/90";
            ^
5 warnings generated.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB