[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: {maint} yacc.c: initialize yylval in pure-parser mode
From: |
Paul Eggert |
Subject: |
Re: {maint} yacc.c: initialize yylval in pure-parser mode |
Date: |
Wed, 19 Sep 2012 07:28:33 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:15.0) Gecko/20120827 Thunderbird/15.0 |
On 09/19/2012 06:05 AM, Akim Demaille wrote:
> I have not seen answers to this message.
Sorry, I missed that one. Thanks for the example;
I think I see the problem now. This appears to be
a bug in GCC -- has someone filed a bug report?
Anyway, we can't expect users to get a fixed GCC, so it'd
be nice to pacify the buggy one. But
instead of initializing yylval to zero, which
is troublesome, how about if we initialize it
to the value of the first input symbol?
That is, instead of this:
yychar = YYEMPTY; /* Cause a token to be read. */
How about if we do something like this:
yychar = YYEMPTY;
#ifdef __GNUC__
/* Avoid diagnostic "'yylval' may be used uninitialized in this
function". Without this extra help, 'gcc -Wmaybe-uninitialized'
is not smart enough to see that yylval is always OK. */
if (YYFINAL != 0 && !yypact_value_is_default (yypact[0]))
yychar = YYLEX;
#endif
That way, GCC will be happy in the usual case. It will optimize
away most of the above gorp, and generate code that simply does
"yychar = YYLEX". And in the unusual case where
where yylval really *isn't* initialized -- because the lexer is
buggy -- GCC will issue the warning, which will be a good thing.
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Akim Demaille, 2012/09/01
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Paul Eggert, 2012/09/01
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Akim Demaille, 2012/09/03
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Akim Demaille, 2012/09/19
- Re: {maint} yacc.c: initialize yylval in pure-parser mode,
Paul Eggert <=
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Akim Demaille, 2012/09/21
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Paul Eggert, 2012/09/21
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Akim Demaille, 2012/09/27
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Paul Eggert, 2012/09/27
- Re: {maint} yacc.c: initialize yylval in pure-parser mode, Akim Demaille, 2012/09/28