mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
yacc.c: avoid generating dead code
We should probably introduce some struct and functions to deal with stack management, rather than open coding it. yyparse would be much nicer to read, and a better model for possible other skeletons. * data/yacc.c (yyparse::yysetstate): Avoid generating code when neither yyoverflow nor YYSTACK_RELOCATE is defined.
This commit is contained in:
14
data/yacc.c
14
data/yacc.c
@@ -1453,11 +1453,14 @@ yysetstate:
|
|||||||
*yyssp = (yytype_int16) yystate;
|
*yyssp = (yytype_int16) yystate;
|
||||||
|
|
||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp)
|
||||||
|
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
|
||||||
|
goto yyexhaustedlab;
|
||||||
|
#else
|
||||||
{
|
{
|
||||||
/* Get the current used size of the three stacks, in elements. */
|
/* Get the current used size of the three stacks, in elements. */
|
||||||
YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
|
YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
|
||||||
|
|
||||||
#ifdef yyoverflow
|
# if defined yyoverflow
|
||||||
{
|
{
|
||||||
/* Give user a chance to reallocate the stack. Use copies of
|
/* Give user a chance to reallocate the stack. Use copies of
|
||||||
these so that the &'s don't force the real ones into
|
these so that the &'s don't force the real ones into
|
||||||
@@ -1479,10 +1482,7 @@ yysetstate:
|
|||||||
yyvs = yyvs1;]b4_locations_if([
|
yyvs = yyvs1;]b4_locations_if([
|
||||||
yyls = yyls1;])[
|
yyls = yyls1;])[
|
||||||
}
|
}
|
||||||
#else /* no yyoverflow */
|
# else /* defined YYSTACK_RELOCATE */
|
||||||
# ifndef YYSTACK_RELOCATE
|
|
||||||
goto yyexhaustedlab;
|
|
||||||
# else
|
|
||||||
/* Extend the stack our own way. */
|
/* Extend the stack our own way. */
|
||||||
if (YYMAXDEPTH <= yystacksize)
|
if (YYMAXDEPTH <= yystacksize)
|
||||||
goto yyexhaustedlab;
|
goto yyexhaustedlab;
|
||||||
@@ -1499,12 +1499,11 @@ yysetstate:
|
|||||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
|
||||||
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
YYSTACK_RELOCATE (yyls_alloc, yyls);])[
|
||||||
# undef YYSTACK_RELOCATE
|
# undef YYSTACK_RELOCATE
|
||||||
if (yyss1 != yyssa)
|
if (yyss1 != yyssa)
|
||||||
YYSTACK_FREE (yyss1);
|
YYSTACK_FREE (yyss1);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
#endif /* no yyoverflow */
|
|
||||||
|
|
||||||
yyssp = yyss + yysize - 1;
|
yyssp = yyss + yysize - 1;
|
||||||
yyvsp = yyvs + yysize - 1;]b4_locations_if([
|
yyvsp = yyvs + yysize - 1;]b4_locations_if([
|
||||||
@@ -1516,6 +1515,7 @@ yysetstate:
|
|||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user