]> git.saurik.com Git - bison.git/commitdiff
* data/glr.c (yyrecoverSyntaxError, yyreturn):
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 25 Aug 2005 06:11:35 +0000 (06:11 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 25 Aug 2005 06:11:35 +0000 (06:11 +0000)
Don't invoke destructor on unresolved entries.
* tests/glr-regression.at
(User destructor for unresolved GLR semantic value): New test case.
Problem reported by Joel E. Denny in:
http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00016.html

ChangeLog
data/glr.c
tests/glr-regression.at

index 4ce49dff819b2d5d1a3b3191612898e7f7587379..0b99e468e4ff7f7c8ef66153002deaf0e182e912 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2005-08-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * data/glr.c (yyrecoverSyntaxError, yyreturn):
+       Don't invoke destructor on unresolved entries.
+       * tests/glr-regression.at
+       (User destructor for unresolved GLR semantic value): New test case.
+       Problem reported by Joel E. Denny in:
+       http://lists.gnu.org/archive/html/bison-patches/2005-08/msg00016.html
+
 2005-08-21  Paul Eggert  <eggert@cs.ucla.edu>
 
        * lib/.cvsignore: Remove realloc.c, strncasecmp.c, xstrdup.c.
index 2d1cbc421dceebf66a7ac91086634b393ce40f1a..16608b61c70036abce3f5c32a479ac6a158c66c0 100644 (file)
@@ -1981,9 +1981,10 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
            }
        }
 ]b4_location_if([[      yystack->yyerror_range[1].yystate.yyloc = yys->yyloc;]])[
-      yydestruct ("Error: popping",
-                 yystos[yys->yylrState],
-                 &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
+      if (yys->yyresolved)
+       yydestruct ("Error: popping",
+                   yystos[yys->yylrState],
+                   &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
       yystack->yytops.yystates[0] = yys->yypred;
       yystack->yynextFree -= 1;
       yystack->yyspaceLeft += 1;
@@ -2183,9 +2184,10 @@ b4_syncline([@oline@], [@ofile@])])dnl
          {
            yyGLRState *yys = yystates[0];
 ]b4_location_if([[       yystack.yyerror_range[1].yystate.yyloc = yys->yyloc;]]
-)[         yydestruct ("Cleanup: popping",
-                       yystos[yys->yylrState],
-                       &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
+)[         if (yys->yyresolved)
+             yydestruct ("Cleanup: popping",
+                         yystos[yys->yylrState],
+                         &yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
            yystates[0] = yys->yypred;
            yystack.yynextFree -= 1;
            yystack.yyspaceLeft += 1;
index 91768a19ebf2ba2d92c8363ba1aee543df01e189..a2d3ce762d18c84bf9390a5db0296e95bf827d20 100644 (file)
@@ -420,3 +420,73 @@ AT_CHECK([[./glr-regr4]], 0,
 ]], [])
 
 AT_CLEANUP
+
+
+## ---------------------------------------------------------------------- ##
+## User destructor for unresolved GLR semantic value                      ##
+## Thanks to Joel E. Denny for this test; see                             ##
+## <http://lists.gnu.org/archive/html/help-bison/2005-07/msg00013.html>.  ##
+## ---------------------------------------------------------------------- ##
+
+AT_SETUP([User destructor for unresolved GLR semantic value])
+
+AT_DATA_GRAMMAR([glr-regr5.y],
+[[%{
+  #include <stdio.h>
+  #include <stdlib.h>
+  static void yyerror (char const *);
+  static int yylex (void);
+  enum { MAGIC_VALUE = -1057808125 }; /* originally chosen at random */
+%}
+
+%glr-parser
+%union { int value; }
+%type <value> start
+
+%destructor {
+  if ($$ != MAGIC_VALUE)
+    {
+      fprintf (stderr, "Bad destructor call.\n");
+      exit (EXIT_FAILURE);
+    }
+} start
+
+%%
+
+start:
+   'a' { $$ = MAGIC_VALUE; }
+   | 'a' { $$ = MAGIC_VALUE; }
+   ;
+
+%%
+
+static int
+yylex (void)
+{
+  static char const *input = "a";
+  return *input++;
+}
+
+static void
+yyerror (char const *msg)
+{
+  printf ("%s\n", msg);
+}
+
+int
+main (void)
+{
+  return yyparse () != 1;
+}
+]])
+
+AT_CHECK([[bison -o glr-regr5.c glr-regr5.y]], 0, [],
+[glr-regr5.y: conflicts: 1 reduce/reduce
+])
+AT_COMPILE([glr-regr5])
+
+AT_CHECK([[./glr-regr5]], 0,
+[syntax is ambiguous
+])
+
+AT_CLEANUP