bison-patches
[Top][All Lists]
Advanced

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

glr.c patch to fix Bison testsuite failure


From: Paul Eggert
Subject: glr.c patch to fix Bison testsuite failure
Date: Sat, 9 Nov 2002 20:34:54 -0800 (PST)

I installed the following Bison patch.

2002-11-09  Paul Eggert  <address@hidden>

        Fix the test failure due to GCC warnings described in
        <http://mail.gnu.org/pipermail/bug-bison/2002-November/001815.html>.

        * data/glr.c (yyis_pact_ninf, yyis_table_ninf): New macros, which
        evaluate to 0 if it's impossible for NINF to be in the respective
        table.
        (yygetLRActions, yyrecoverParseError): Use them.

Index: data/glr.c
===================================================================
RCS file: /cvsroot/bison/bison/data/glr.c,v
retrieving revision 1.29
diff -p -u -r1.29 glr.c
--- data/glr.c  7 Nov 2002 12:52:19 -0000       1.29
+++ data/glr.c  9 Nov 2002 23:14:37 -0000
@@ -707,12 +707,17 @@ yylhsNonterm (yyRuleNum yyrule)
   return yyr1[yyrule];
 }
 
+#define yyis_pact_ninf(yystate) \
+  ]m4_if(m4_eval(b4_pact_ninf < b4_pact_min), 1,
+        0,
+        ((yystate) == YYPACT_NINF))[
+
 /** True iff LR state STATE has only a default reduction (regardless
  *  of token). */
 static inline bool
 yyisDefaultedState (yyStateNum yystate)
 {
-  return yypact[yystate] == YYPACT_NINF;
+  return yyis_pact_ninf (yypact[yystate]);
 }
 
 /** The default reduction for STATE, assuming it has one. */
@@ -722,6 +727,11 @@ yydefaultAction (yyStateNum yystate)
   return yydefact[yystate];
 }
 
+#define yyis_table_ninf(yyindex) \
+  ]m4_if(m4_eval(b4_table_ninf < b4_table_min), 1,
+        0,
+        ((yyindex) == YYTABLE_NINF))[
+
 /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
  *  Result R means
  *    R < 0:  Reduce on rule -R.
@@ -740,7 +750,7 @@ yygetLRActions (yyStateNum yystate, int 
       *yyaction = -yydefact[yystate];
       *yyconflicts = yyconfl;
     }
-  else if (yytable[yyindex] != YYTABLE_NINF)
+  else if (! yyis_table_ninf (yyindex))
     {
       *yyaction = yytable[yyindex];
       *yyconflicts = yyconfl + yyconflp[yyindex];
@@ -1645,7 +1655,7 @@ yyrecoverParseError (yyGLRStack* yystack
        *yytokenp = YYTRANSLATE (yychar);
        YYDPRINTF ((stderr, "Next token is %s\n", yytokenName (*yytokenp)));
        yyj = yypact[yystack->yytops.yystates[0]->yylrState];
-       if (yyj == YYPACT_NINF)
+       if (yyis_pact_ninf (yyj))
          /* Something's not right; we shouldn't be here.  */
          yyFail (yystack][]b4_lpure_args[, NULL);
        yyj += *yytokenp;
@@ -1654,7 +1664,7 @@ yyrecoverParseError (yyGLRStack* yystack
            if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0)
              return;
          }
-       else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF)
+       else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj]))
          return;
       }
 
@@ -1672,14 +1682,18 @@ yyrecoverParseError (yyGLRStack* yystack
   /* Now pop stack until we find a state that shifts the error token. */
   while (yystack->yytops.yystates[0] != NULL)
     {
-      yyj = yypact[yystack->yytops.yystates[0]->yylrState] + YYTERROR;
-      if (yyj != YYPACT_NINF + YYTERROR && yyj >= 0 && yyj <= YYLAST &&
-         yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj]))
-       {
-         yyglrShift (yystack, 0, yytable[yyj],
-                     yystack->yytops.yystates[0]->yyposn,
-                     *yylvalp, yyllocp]b4_user_args[);
-         break;
+      yyj = yypact[yystack->yytops.yystates[0]->yylrState];
+      if (! yyis_pact_ninf (yyj))
+       {
+         yyj += YYTERROR;
+         if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
+             && yyisShiftAction (yytable[yyj]))
+           {
+             yyglrShift (yystack, 0, yytable[yyj],
+                         yystack->yytops.yystates[0]->yyposn,
+                         *yylvalp, yyllocp]b4_user_args[);
+             break;
+           }
        }
       yystack->yytops.yystates[0] = yystack->yytops.yystates[0]->yypred;
       yystack->yynextFree -= 1;




reply via email to

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