]> git.saurik.com Git - bison.git/commitdiff
portability: fix pointer arithmetic to conform to C standard.
authorJoel E. Denny <jdenny@clemson.edu>
Sat, 3 Apr 2010 18:58:22 +0000 (14:58 -0400)
committerJoel E. Denny <jdenny@clemson.edu>
Sat, 3 Apr 2010 18:58:22 +0000 (14:58 -0400)
Reported by Tys Lefering at
<http://lists.gnu.org/archive/html/bug-bison/2010-03/msg00035.html>.
This fix is already implemented in glr.c and does not apply to
lalr1.java.
* data/lalr1.cc (yy::parser::parse): Increase size of
yyerror_range and adjust subscripting so you don't have to
subtract one from the beginning of the array.
* data/yacc.c (b4_declare_parser_state_variables,
yyparse, yypush_parse): Likewise.

ChangeLog
data/lalr1.cc
data/yacc.c
src/parse-gram.c
src/parse-gram.h

index 507576bf01031ac035d5448835b6d7631156df2c..ec42c73ba8c6a3acaa8120fe6555107eedb0ade5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2010-04-03  Joel E. Denny  <jdenny@ces.clemson.edu>
+
+       portability: fix pointer arithmetic to conform to C standard.
+       Reported by Tys Lefering at
+       <http://lists.gnu.org/archive/html/bug-bison/2010-03/msg00035.html>.
+       This fix is already implemented in glr.c and does not apply to
+       lalr1.java.
+       * data/lalr1.cc (yy::parser::parse): Increase size of
+       yyerror_range and adjust subscripting so you don't have to
+       subtract one from the beginning of the array.
+       * data/yacc.c (b4_declare_parser_state_variables,
+       yyparse, yypush_parse): Likewise.
+
 2010-03-31  Joel E. Denny  <jdenny@ces.clemson.edu>
 
        portability: fix test suite for GCC 4.5's new #error message.
index 6c66dd1bd676f94f6a6cd091586d6ebb33c39d4c..183ddcd94be3c9e7ebab5cd584d3245cae7e8d67 100644 (file)
@@ -538,7 +538,7 @@ do {                                        \
     /// Location of the lookahead.
     location_type yylloc;
     /// The locations where the error started and ended.
-    location_type yyerror_range[2];
+    location_type yyerror_range[3];
 
     /// $$.
     semantic_type yyval;
@@ -709,7 +709,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
 b4_error_verbose_if([, yytoken])[));
       }
 
-    yyerror_range[0] = yylloc;
+    yyerror_range[1] = yylloc;
     if (yyerrstatus_ == 3)
       {
        /* If just tried and failed to reuse lookahead token after an
@@ -744,7 +744,7 @@ b4_error_verbose_if([, yytoken])[));
     if (false)
       goto yyerrorlab;
 
-    yyerror_range[0] = yylocation_stack_[yylen - 1];
+    yyerror_range[1] = yylocation_stack_[yylen - 1];
     /* Do not reclaim the symbols of the rule which action triggered
        this YYERROR.  */
     yypop_ (yylen);
@@ -776,7 +776,7 @@ b4_error_verbose_if([, yytoken])[));
        if (yystate_stack_.height () == 1)
        YYABORT;
 
-       yyerror_range[0] = yylocation_stack_[0];
+       yyerror_range[1] = yylocation_stack_[0];
        yydestruct_ ("Error: popping",
                     yystos_[yystate],
                     &yysemantic_stack_[0], &yylocation_stack_[0]);
@@ -785,10 +785,10 @@ b4_error_verbose_if([, yytoken])[));
        YY_STACK_PRINT ();
       }
 
-    yyerror_range[1] = yylloc;
+    yyerror_range[2] = yylloc;
     // Using YYLLOC is tempting, but would change the location of
     // the lookahead.  YYLOC is available though.
-    YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
+    YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
     yysemantic_stack_.push (yylval);
     yylocation_stack_.push (yyloc);
 
index 67e18404508433d57963cd0a71a0ad80aacb4ee6..ed44a4c4e7514bd2b0306a4a5a8a8b2507801e55 100644 (file)
@@ -1072,7 +1072,7 @@ m4_define([b4_declare_parser_state_variables],
     YYLTYPE *yylsp;
 
     /* The locations where the error started and ended.  */
-    YYLTYPE yyerror_range[2];
+    YYLTYPE yyerror_range[3];
 ]])[
     YYSIZE_T yystacksize;
 ]])
@@ -1533,7 +1533,7 @@ yyerrlab:
 #endif
     }
 
-]b4_locations_if([[  yyerror_range[0] = yylloc;]])[
+]b4_locations_if([[  yyerror_range[1] = yylloc;]])[
 
   if (yyerrstatus == 3)
     {
@@ -1570,7 +1570,7 @@ yyerrorlab:
   if (/*CONSTCOND*/ 0)
      goto yyerrorlab;
 
-]b4_locations_if([[  yyerror_range[0] = yylsp[1-yylen];
+]b4_locations_if([[  yyerror_range[1] = yylsp[1-yylen];
 ]])[  /* Do not reclaim the symbols of the rule which action triggered
      this YYERROR.  */
   YYPOPSTACK (yylen);
@@ -1604,7 +1604,7 @@ yyerrlab1:
       if (yyssp == yyss)
        YYABORT;
 
-]b4_locations_if([[      yyerror_range[0] = *yylsp;]])[
+]b4_locations_if([[      yyerror_range[1] = *yylsp;]])[
       yydestruct ("Error: popping",
                  yystos[yystate], yyvsp]b4_locations_if([, yylsp])[]b4_user_args[);
       YYPOPSTACK (1);
@@ -1614,10 +1614,10 @@ yyerrlab1:
 
   *++yyvsp = yylval;
 ]b4_locations_if([[
-  yyerror_range[1] = yylloc;
+  yyerror_range[2] = yylloc;
   /* Using YYLLOC is tempting, but would change the location of
      the lookahead.  YYLOC is available though.  */
-  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
+  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
   *++yylsp = yyloc;]])[
 
   /* Shift the error token.  */
index 04a934ef4ab4d3d6b0b6bdc0a45d7ef9c0cc759f..34c28022e75b9070751a6f74e31bef28baba9ea8 100644 (file)
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.4.1.61-f1ce.  */
+/* A Bison parser, made by GNU Bison 2.4.2.5-1849.  */
 
 /* Skeleton implementation for Bison's Yacc-like parsers in C
    
@@ -45,7 +45,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.4.1.61-f1ce"
+#define YYBISON_VERSION "2.4.2.5-1849"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -1640,7 +1640,7 @@ YYLTYPE yylloc;
     YYLTYPE *yylsp;
 
     /* The locations where the error started and ended.  */
-    YYLTYPE yyerror_range[2];
+    YYLTYPE yyerror_range[3];
 
     YYSIZE_T yystacksize;
 
@@ -2703,7 +2703,7 @@ yyerrlab:
 #endif
     }
 
-  yyerror_range[0] = yylloc;
+  yyerror_range[1] = yylloc;
 
   if (yyerrstatus == 3)
     {
@@ -2740,7 +2740,7 @@ yyerrorlab:
   if (/*CONSTCOND*/ 0)
      goto yyerrorlab;
 
-  yyerror_range[0] = yylsp[1-yylen];
+  yyerror_range[1] = yylsp[1-yylen];
   /* Do not reclaim the symbols of the rule which action triggered
      this YYERROR.  */
   YYPOPSTACK (yylen);
@@ -2774,7 +2774,7 @@ yyerrlab1:
       if (yyssp == yyss)
        YYABORT;
 
-      yyerror_range[0] = *yylsp;
+      yyerror_range[1] = *yylsp;
       yydestruct ("Error: popping",
                  yystos[yystate], yyvsp, yylsp);
       YYPOPSTACK (1);
@@ -2784,10 +2784,10 @@ yyerrlab1:
 
   *++yyvsp = yylval;
 
-  yyerror_range[1] = yylloc;
+  yyerror_range[2] = yylloc;
   /* Using YYLLOC is tempting, but would change the location of
      the lookahead.  YYLOC is available though.  */
-  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
+  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
   *++yylsp = yyloc;
 
   /* Shift the error token.  */
index 133555d4eb38fd1f708eafa600a566e13b9eb189..7be84a991dbe5e2d37267ce771c43862ed168680 100644 (file)
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.4.1.61-f1ce.  */
+/* A Bison parser, made by GNU Bison 2.4.2.5-1849.  */
 
 /* Skeleton interface for Bison's Yacc-like parsers in C