mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* 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:
22
data/yacc.c
22
data/yacc.c
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user