Suppress signed/unsigned comparison warnings for yycheck.

* data/c.m4 (b4_safest_int_type): New macro.
* data/glr.c, data/lalr1.cc: Wherever you compare yycheck[i] against
a signed int type, cast it to b4_safest_int_type first.
* data/yacc.c: Likewise.
(b4_safest_int_type): Overwrite the one from c.m4 since b4_int_type is
also overwritten.
This commit is contained in:
Joel E. Denny
2006-08-10 01:18:50 +00:00
parent 9c4371263f
commit 06e8700a00
7 changed files with 162 additions and 129 deletions

View File

@@ -1048,7 +1048,8 @@ yygetLRActions (yyStateNum yystate, int yytoken,
int* yyaction, const short int** yyconflicts)
{
int yyindex = yypact[yystate] + yytoken;
if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
if (yyindex < 0 || YYLAST < yyindex
|| (]b4_safest_int_type[)yycheck[yyindex] != yytoken)
{
*yyaction = -yydefact[yystate];
*yyconflicts = yyconfl;
@@ -1070,7 +1071,8 @@ yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
{
int yyr;
yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
if (0 <= yyr && yyr <= YYLAST
&& (]b4_safest_int_type[)yycheck[yyr] == yystate)
return yytable[yyr];
else
return yydefgoto[yylhs - YYNTOKENS];
@@ -2120,7 +2122,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
if ((]b4_safest_int_type[)yycheck[yyx + yyn] == yyx
&& yyx != YYTERROR)
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
@@ -2216,7 +2219,8 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
if (yyis_pact_ninf (yyj))
return;
yyj += yytoken;
if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken)
if (yyj < 0 || YYLAST < yyj
|| (]b4_safest_int_type[)yycheck[yyj] != yytoken)
{
if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0)
return;