bug-bison
[Top][All Lists]
Advanced

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

Re: CRT in generated parser


From: Akim Demaille
Subject: Re: CRT in generated parser
Date: Sun, 30 Aug 2020 10:17:12 +0200


> Le 30 août 2020 à 09:48, Akim Demaille <akim@lrde.epita.fr> a écrit :
> 
> Hi Kovalex,
> 
> commit 629902bc603d4bd07bb5c45c7ed638f4fbf3b91f
> Author: Akim Demaille <akim.demaille@gmail.com>
> Date:   Sun Aug 30 09:45:34 2020 +0200
> 
>    c: always use YYMALLOC/YYFREE
> 
>    Reported by Kovalex <kovalex.pro@gmail.com>.
>    https://lists.gnu.org/r/bug-bison/2020-08/msg00015.html
> 
>    * data/skeletons/yacc.c: Don't make direct calls to malloc/free.

I'll install this instead, with a test.  I was being lazy...

commit a1b7fef045124971053edb0e6d570d0e15cb04f5
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Sun Aug 30 09:45:34 2020 +0200

    c: always use YYMALLOC/YYFREE
    
    Reported by Kovalex <kovalex.pro@gmail.com>.
    https://lists.gnu.org/r/bug-bison/2020-08/msg00015.html
    
    * data/skeletons/yacc.c: Don't make direct calls to malloc/free.
    * tests/calc.at: Check it.

diff --git a/NEWS b/NEWS
index 68bbbb81..a5c59f0d 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ GNU Bison NEWS
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes
+
+  Push parsers use YYMALLOC/YYFREE instead of direct calls to malloc/free.
 
 * Noteworthy changes in release 3.7.1 (2020-08-02) [stable]
 
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 9ec153ac..c695a039 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -1486,7 +1486,7 @@ yypstate_new (void)
   yypstate *yyps;]b4_pure_if([], [[
   if (yypstate_allocated)
     return YY_NULLPTR;]])[
-  yyps = YY_CAST (yypstate *, malloc (sizeof *yyps));
+  yyps = YY_CAST (yypstate *, YYMALLOC (sizeof *yyps));
   if (!yyps)
     return YY_NULLPTR;]b4_pure_if([], [[
   yypstate_allocated = 1;]])[
@@ -1515,7 +1515,7 @@ yypstate_delete (yypstate *yyps)
 #endif]b4_lac_if([[
       if (yyes != yyesa)
         YYSTACK_FREE (yyes);]])[
-      free (yyps);]b4_pure_if([], [[
+      YYFREE (yyps);]b4_pure_if([], [[
       yypstate_allocated = 0;]])[
     }
 }
diff --git a/tests/calc.at b/tests/calc.at
index ee75bf27..e24d6c83 100644
--- a/tests/calc.at
+++ b/tests/calc.at
@@ -915,6 +915,12 @@ AT_BISON_OPTION_PUSHDEFS([$1])
 
 AT_DATA_CALC_Y([$1])
 AT_FULL_COMPILE(AT_JAVA_IF([[Calc]], [[calc]]), AT_DEFINES_IF([[lex], [main]], 
[[], []]), [$2], [-Wno-deprecated])
+
+AT_YACC_IF(
+  [# No direct calls to malloc/free.
+  AT_CHECK([[$EGREP '(malloc|free) *\(' calc.[ch] | $EGREP -v 'INFRINGES ON 
USER NAME SPACE']],
+           [1])])
+
 AT_PUSH_IF([AT_JAVA_IF(
  [# Verify that this is a push parser.
   AT_CHECK_JAVA_GREP([[Calc.java]],
diff --git a/tests/local.at b/tests/local.at
index 5465bd85..a4782362 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -390,6 +390,7 @@ AT_LOCATION_TYPE_SPAN_IF(
 
 
 AT_GLR_IF([AT_KEYWORDS([glr])])
+AT_PUSH_IF([AT_KEYWORDS([push])])
 ])# _AT_BISON_OPTION_PUSHDEFS
 
 




reply via email to

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