bug-bison
[Top][All Lists]
Advanced

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

Re: yyabortlab bug report (and proposed fix)


From: Hans Aberg
Subject: Re: yyabortlab bug report (and proposed fix)
Date: Sun, 22 May 2005 11:34:51 +0200

There might be a problem also at all the other places where yydestruct() occurs.

At 22:23 -0700 2005/05/21, Paul Eggert wrote:
Wolfgang Spraul <address@hidden> writes:

 One could argue why setting yychar = YYEMPTY is necessary,

True; thanks for pointing it out.

 I have crashes in some cases where the lookahead item is destructed
 twice.

Thanks very much for mentioning it.  I installed the following
generalization of the patch idea that you proposed.

2005-05-21  Paul Eggert  <address@hidden>

        Fix a destructor bug reported by Wolfgang Spraul in
        <http://lists.gnu.org/archive/html/bug-bison/2005-05/msg00042.html>.
        * data/yacc.c (yyabortlab): Don't call destructor, and
        don't set yychar to EMPTY.
        (yyoverflowlab): Don't call destructor.
        (yyreturn): Call destructor, if yychar is neither YYEOF nor YYEMPTY.
        * tests/calc.at (AT_CHECK_CALC): Expect one fewer output lines,
        since we no longer output the message "discarding lookahead token
        end of input ()".

Index: data/yacc.c
===================================================================
RCS file: /cvsroot/bison/bison/data/yacc.c,v
retrieving revision 1.88
diff -p -u -r1.88 yacc.c
--- data/yacc.c 14 May 2005 06:49:46 -0000      1.88
+++ data/yacc.c 22 May 2005 05:10:29 -0000
@@ -135,7 +135,7 @@ m4_changecom()
 m4_divert(0)dnl
 @output @output_parser_name@
 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
-             [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004])[
+             [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005])[

 /* As a special exception, when this file is copied by Bison into a
    Bison output file, you may use that output file without restriction.
@@ -1296,9 +1296,6 @@ yyacceptlab:
 | yyabortlab -- YYABORT comes here.  |
 `-----------------------------------*/
 yyabortlab:
-  yydestruct (_("Error: discarding lookahead"),
-              yytoken, &yylval]b4_location_if([, &yylloc])[);
-  yychar = YYEMPTY;
   yyresult = 1;
   goto yyreturn;

@@ -1308,13 +1305,14 @@ yyabortlab:
 `----------------------------------------------*/
 yyoverflowlab:
   yyerror (]b4_yyerror_args[_("parser stack overflow"));
-  yydestruct (_("Error: discarding lookahead"),
-             yytoken, &yylval]b4_location_if([, &yylloc])[);
   yyresult = 2;
   /* Fall through.  */
 #endif

 yyreturn:
+  if (yychar != YYEOF && yychar != YYEMPTY)
+     yydestruct (_("Error: discarding lookahead"),
+                yytoken, &yylval]b4_location_if([, &yylloc])[);
   if (yyssp != yyss)
     for (;;)
       {
@@ -1337,7 +1335,7 @@ b4_epilogue
 m4_if(b4_defines_flag, 0, [],
 address@hidden @output_header_name@
 b4_copyright([Skeleton parser for Yacc-like parsing with Bison],
-             [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004])
+             [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005])

 /* As a special exception, when this file is copied by Bison into a
    Bison output file, you may use that output file without restriction.
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.73
diff -p -u -r1.73 calc.at
--- tests/calc.at       14 May 2005 06:49:48 -0000      1.73
+++ tests/calc.at       22 May 2005 05:10:30 -0000
@@ -480,7 +480,7 @@ _AT_CHECK_CALC_ERROR([$1], [1],
                      [16],
                      [2.0: syntax error, unexpected '+'])
 # Exercise error messages with EOF: work on an empty file.
-_AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [5],
+_AT_CHECK_CALC_ERROR([$1], [1], [/dev/null], [4],
                      [1.0: syntax error, unexpected end of input])

 # Exercise the error token: without it, we die at the first error,


--
  Hans Aberg




reply via email to

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