bison-patches
[Top][All Lists]
Advanced

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

yacc.c: avoid generating dead code


From: Akim Demaille
Subject: yacc.c: avoid generating dead code
Date: Sun, 25 Nov 2018 08:13:23 +0100

commit 660811a6c5aad3e58bfb926d3caab160da07bedb
Author: Akim Demaille <address@hidden>
Date:   Sat Nov 24 13:23:52 2018 +0100

    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.

diff --git a/data/yacc.c b/data/yacc.c
index c3782333..3f2883c6 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -1453,11 +1453,14 @@ yysetstate:
   *yyssp = (yytype_int16) yystate;
 
   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.  */
       YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
 
-#ifdef yyoverflow
+# if defined yyoverflow
       {
         /* Give user a chance to reallocate the stack.  Use copies of
            these so that the &'s don't force the real ones into
@@ -1479,10 +1482,7 @@ yysetstate:
         yyvs = yyvs1;]b4_locations_if([
         yyls = yyls1;])[
       }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
-      goto yyexhaustedlab;
-# else
+# else /* defined YYSTACK_RELOCATE */
       /* Extend the stack our own way.  */
       if (YYMAXDEPTH <= yystacksize)
         goto yyexhaustedlab;
@@ -1499,12 +1499,11 @@ yysetstate:
         YYSTACK_RELOCATE (yyss_alloc, yyss);
         YYSTACK_RELOCATE (yyvs_alloc, yyvs);]b4_locations_if([
         YYSTACK_RELOCATE (yyls_alloc, yyls);])[
-#  undef YYSTACK_RELOCATE
+# undef YYSTACK_RELOCATE
         if (yyss1 != yyssa)
           YYSTACK_FREE (yyss1);
       }
 # endif
-#endif /* no yyoverflow */
 
       yyssp = yyss + yysize - 1;
       yyvsp = yyvs + yysize - 1;]b4_locations_if([
@@ -1516,6 +1515,7 @@ yysetstate:
       if (yyss + yystacksize - 1 <= yyssp)
         YYABORT;
     }
+#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
 
   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
 




reply via email to

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