bison-patches
[Top][All Lists]
Advanced

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

Re: Purity of yyerror etc.


From: Akim Demaille
Subject: Re: Purity of yyerror etc.
Date: 04 Nov 2002 09:35:23 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)

>>>>> "Paul" == Paul Eggert <address@hidden> writes:

Paul> There is a problem with the current approach, which may be
Paul> relevant: "configure --enable-gcc-warnings; make check" fails
Paul> due to warnings about unused parameters.  Here's an (edited)
Paul> testsuite.log to illustrate.

All the issues were related to the test suite itself.  I'm installing
the following patch, but read bellow.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * tests/glr-regr1.at (Badly Collapsed GLR States): Prototype yylex
        and yyerror.
        Have yyerror `use' its arguments.
        * tests/calc.at (AT_CHECK_PUSHDEFS): AT_YYERROR_SEES_LOC_IF
        returns true when location & yacc & pure & parse-param.
        (_AT_DATA_CALC_Y): Let yyerror ``use'' its arguments.

Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.39
diff -u -u -r1.39 calc.at
--- tests/calc.at 3 Nov 2002 16:41:57 -0000 1.39
+++ tests/calc.at 4 Nov 2002 08:28:24 -0000
@@ -158,6 +158,7 @@
          ]AT_YYERROR_ARG_LOC_IF([, YYLTYPE *yylloc])[
          ]AT_PARAM_IF([, value_t *result, int *count])[)
 {
+]AT_PARAM_IF([(void) result; (void) count; ])[
 ]AT_YYERROR_SEES_LOC_IF([
   fprintf (stderr, "%d.%d-%d.%d: ",
           LOC.first_line, LOC.first_column,
@@ -441,10 +442,11 @@
 m4_pushdef([AT_YYERROR_ARG_LOC_IF],
 [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
                     [$2])])
-# yyerror cannot see the locations if !glr & pure.
+# yyerror cannot see the locations if !glr & pure & !param.
 m4_pushdef([AT_YYERROR_SEES_LOC_IF],
 [AT_LOCATION_IF([AT_GLR_IF([$1],
-                           [AT_PURE_IF([$2], [$1])])],
+                           [AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
+                                       [$1])])],
                 [$2])])
 ])
 
Index: tests/glr-regr1.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/glr-regr1.at,v
retrieving revision 1.1
diff -u -u -r1.1 glr-regr1.at
--- tests/glr-regr1.at 30 Oct 2002 02:03:14 -0000 1.1
+++ tests/glr-regr1.at 4 Nov 2002 08:28:24 -0000
@@ -29,6 +29,8 @@
 
 #define YYSTYPE int
 static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1);
+int yylex (void);
+int yyerror (char const *msg);
 %}
 
 
@@ -52,24 +54,29 @@
 
 static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1)
 {
+  (void) x0;
+  (void) x1;
   printf ("<OR>\n");
   return 0;
 }
 
-int main()
+int
+main (void)
 {
   yyparse();
   return 0;
 }
 
-int yyerror(char const *msg)
+int
+yyerror (char const *msg)
 {
   printf("%s\n", msg);
   exit(4);
 }
 
 
-int yylex()
+int
+yylex (void)
 {
   while (1) {
     int ch = fgetc(stdin);
@@ -86,7 +93,7 @@
 [glr-regr1.y: warning: 1 shift/reduce conflict
 ])
 AT_COMPILE([glr-regr1])
-AT_CHECK([[echo BPBPB | ./glr-regr1]], 0, 
+AT_CHECK([[echo BPBPB | ./glr-regr1]], 0,
 [[E -> 'B'
 E -> 'B'
 E -> E 'P' E




There remains one failure due to a warning:

102. glr-regr1.at:21: testing Badly Collapsed GLR States...
glr-regr1.at:94: bison -o glr-regr1.c glr-regr1.y
glr-regr1.at:95: $CC $CFLAGS $CPPFLAGS glr-regr1.c -o glr-regr1
stderr:
cc1: warnings being treated as errors
glr-regr1.c: In function `yygetLRActions':
glr-regr1.c:627: warning: comparison is always true due to limited range of 
data 
type
glr-regr1.c: In function `yyrecoverParseError':
glr-regr1.c:1541: warning: comparison is always true due to limited range of 
data
 type
glr-regr1.at:95: exit code was 1, expected 0
102. glr-regr1.at:21: FAILED near `glr-regr1.at:95'


Both come from:

   617  static inline void
   618  yygetLRActions (yyStateNum yystate, int yytoken,
   619                  int* yyaction, const short** yyconflicts)
   620  {
   621    int yyindex = yypact[yystate] + yytoken;
   622    if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
   623      {
   624        *yyaction = -yydefact[yystate];
   625        *yyconflicts = yyconfl;
   626      }
   627    else if (yytable[yyindex] != YYTABLE_NINF)
   628      {
   629        *yyaction = yytable[yyindex];
   630        *yyconflicts = yyconfl + yyconflp[yyindex];
   631      }
   632    else
   633      {
   634        *yyaction = 0;
   635        *yyconflicts = yyconfl + yyconflp[yyindex];
   636      }
   637  }

and:

  1540            }
  1541          else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF)
  1542            return;
  1543        }

with

   273  #define YYTABLE_NINF -1
   274  static const unsigned char yytable[] =
   275  {
   276         1,     4,     5,     6
   277  };

i.e., we are comparing a signed, with an unsigned.  This does not
happen in realistic cases, but there is something to do about it.
I'll think about it.




reply via email to

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