help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pure-parser warning: ‘yylval’ is used uninitialized in this function


From: Kaiwang Chen
Subject: pure-parser warning: ‘yylval’ is used uninitialized in this function
Date: Thu, 08 May 2008 16:20:02 +0800

Hello,

GCC with "-Os -Wall -Werror" complains in the case of pure-parser, while
without -Os it works well. Any help? Thanks in advance.

$ bison -o parse.c parse.y
$ gcc -Os -Wall -Werror  -c parse.c -o parse.o
cc1: warnings being treated as errors
parse.c: In function ‘yyparse’:
parse.c:1247: warning: ‘yylval’ is used uninitialized in this function

The generated problem code snippet is:

1246   yystate = yyn;
1247   *++yyvsp = yylval;
1248 
1249   goto yynewstate;
1250 
1251 
1252 /*-----------------------------------------------------------.
1253 | yydefault -- do the default action for the current state.  |
1254 `-----------------------------------------------------------*/
1255 yydefault:



$gcc -Wall -Werror  -c parse.c -o parse.o
(compiles well)

$ uname -a
Linux test64 2.6.21-2950.fc8xen #1 SMP Tue Oct 23 12:23:33 EDT 2007
x86_64 x86_64 x86_64 GNU/Linux
$ gcc --version
gcc (GCC) 4.1.2 20070925 (Red Hat 4.1.2-33)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
$ bison --version
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman.

Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.


The source code is 

$ cat parse.y
%{
#define YYSTYPE int

static int yylex(YYSTYPE *lvalp);
static int yyerror(char const *s);
%}
%pure-parser
%start t
%%

t: 'a'

%%

static int yylex(YYSTYPE *lvalp)
{
    return YYEOF;
}

static int yyerror(char const *s)
{
       return 0;
}

int main()
{
    return yyparse();
}



Thanks,
Kaiwang





reply via email to

[Prev in Thread] Current Thread [Next in Thread]