]> 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, 10 Apr 2010 01:08:37 +0000 (21:08 -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.
(cherry picked from commit 48f4100a8299918a3abc9c5d29db85319cad3cee)

Conflicts:

data/yacc.c
src/parse-gram.c
src/parse-gram.h

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

index 23f92aefee237e32fabb6c593c8439de81f0eadd..974b7bf7b2beb700c875f5d40ca2d317a22ca635 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-04-05  Akim Demaille  <demaille@gostai.com>
 
        remove useless include.
index 86cc71359930fc6a7e5b6705996ef82f87558ded..d56c8b825edb0f1288addec3284d4c0dfd691f60 100644 (file)
@@ -553,7 +553,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;
@@ -723,7 +723,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
        error (yylloc, yysyntax_error_ (yystate, yytoken));
       }
 
-    yyerror_range[0] = yylloc;
+    yyerror_range[1] = yylloc;
     if (yyerrstatus_ == 3)
       {
        /* If just tried and failed to reuse lookahead token after an
@@ -758,7 +758,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
     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);
@@ -790,7 +790,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
        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]);
@@ -799,10 +799,10 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
        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 4274673d95fbc0f569a92aae96fc048360557356..539b6544f29d7136850ae7e92d3582105b46d941 100644 (file)
@@ -203,7 +203,7 @@ m4_define([b4_declare_parser_state_variables], [b4_pure_if([[
     YYLTYPE *yylsp;
 
     /* The locations where the error started and ended.  */
-    YYLTYPE yyerror_range[2];]])[
+    YYLTYPE yyerror_range[3];]])[
 
     YYSIZE_T yystacksize;]])
 
@@ -1568,7 +1568,7 @@ yyerrlab:
 #endif
     }
 
-]b4_locations_if([[  yyerror_range[0] = yylloc;]])[
+]b4_locations_if([[  yyerror_range[1] = yylloc;]])[
 
   if (yyerrstatus == 3)
     {
@@ -1605,7 +1605,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);
@@ -1639,7 +1639,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);
@@ -1649,10 +1649,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 701b4c5e64d4202805c1b3548e0f22e8e6184607..4d4e1722debc4076b73306646c0fc2640e3b0b96 100644 (file)
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.4.1.184-510df.  */
+/* A Bison parser, made by GNU Bison 2.4.1.206-8a8b-dirty.  */
 
 /* Skeleton implementation for Bison's Yacc-like parsers in C
    
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.4.1.184-510df"
+#define YYBISON_VERSION "2.4.1.206-8a8b-dirty"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -1677,7 +1677,7 @@ YYLTYPE yylloc;
     YYLTYPE *yylsp;
 
     /* The locations where the error started and ended.  */
-    YYLTYPE yyerror_range[2];
+    YYLTYPE yyerror_range[3];
 
     YYSIZE_T yystacksize;
 
@@ -2770,7 +2770,7 @@ yyerrlab:
 #endif
     }
 
-  yyerror_range[0] = yylloc;
+  yyerror_range[1] = yylloc;
 
   if (yyerrstatus == 3)
     {
@@ -2807,7 +2807,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);
@@ -2841,7 +2841,7 @@ yyerrlab1:
       if (yyssp == yyss)
        YYABORT;
 
-      yyerror_range[0] = *yylsp;
+      yyerror_range[1] = *yylsp;
       yydestruct ("Error: popping",
                  yystos[yystate], yyvsp, yylsp);
       YYPOPSTACK (1);
@@ -2851,10 +2851,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 77a6c83be6ce018235890163d588f561d6e146d1..189fb7d6e10b3930643160e2d26401ac47cb995c 100644 (file)
@@ -1,4 +1,4 @@
-/* A Bison parser, made by GNU Bison 2.4.1.184-510df.  */
+/* A Bison parser, made by GNU Bison 2.4.1.206-8a8b-dirty.  */
 
 /* Skeleton interface for Bison's Yacc-like parsers in C