]> git.saurik.com Git - bison.git/blobdiff - data/yacc.c
Fix a destructor bug reported by Wolfgang Spraul in
[bison.git] / data / yacc.c
index bc8087dd63edcc661c7431c027b537ac7f5b7953..07568b95537359d7abfd714068bdf2fa76947468 100644 (file)
@@ -17,8 +17,8 @@ m4_divert(-1)                                                       -*- C -*-
 
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-# 02111-1307  USA
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301  USA
 
 
 
@@ -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.
@@ -1203,15 +1203,7 @@ yyerrlab:
           /* If at end of input, pop the error token,
             then the rest of the stack, then return failure.  */
          if (yychar == YYEOF)
-            for (;;)
-              {
-]b4_location_if([[                 yyerror_range[0] = *yylsp;]])[
-                YYPOPSTACK;
-                if (yyssp == yyss)
-                  YYABORT;
-                yydestruct (_("Error: popping"),
-                             yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
-              }
+           YYABORT;
         }
       else
        {
@@ -1304,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;
 
@@ -1321,6 +1310,19 @@ yyoverflowlab:
 #endif
 
 yyreturn:
+  if (yychar != YYEOF && yychar != YYEMPTY)
+     yydestruct (_("Error: discarding lookahead"),
+                yytoken, &yylval]b4_location_if([, &yylloc])[);
+  if (yyssp != yyss)
+    for (;;)
+      {
+]b4_location_if([[     yyerror_range[0] = *yylsp;]])[
+       YYPOPSTACK;
+       if (yyssp == yyss)
+         break;
+       yydestruct (_("Error: popping"),
+                   yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
+      }
 #ifndef yyoverflow
   if (yyss != yyssa)
     YYSTACK_FREE (yyss);
@@ -1333,7 +1335,7 @@ b4_epilogue
 m4_if(b4_defines_flag, 0, [],
 [@output @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.