* tests/actions.at: Test that stack overflow invokes destructors.

From Marcus Holland-Moritz.
* data/yacc.c (yyerrlab): Move the code that destroys the stack
from here....
(yyreturn): to here.  That way, destructors are called properly
even if the stack overflows, or the user calls YYACCEPT or
YYABORT.  Stack-overflow problem reported by Marcus Holland-Moritz.
(yyoverflowlab): Destroy the lookahead.
This commit is contained in:
Paul Eggert
2005-05-02 04:52:33 +00:00
parent b9c9f76197
commit 80ce3401e9
3 changed files with 84 additions and 10 deletions

View File

@@ -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
{
@@ -1316,11 +1308,23 @@ 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 (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);