bison-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] yysyntax_error: make it manage its own memory.


From: Joel E. Denny
Subject: Re: [PATCH] yysyntax_error: make it manage its own memory.
Date: Mon, 21 Sep 2009 21:30:05 -0400 (EDT)
User-agent: Alpine 1.00 (DEB 882 2007-12-20)

Hi Akim.

On Wed, 16 Sep 2009, Akim Demaille wrote:

> Le 11 sept. 2009 à 09:40, Joel E. Denny a écrit :
> 
> > +# gcc warns about tautologies and fallacies involving comparisons for
> > +# unsigned char.  However, it doesn't produce these same warnings for
> > +# size_t and many other types when the warnings would seem to make just
> > +# as much sense.  We ignore the warnings.
> > +CFLAGS=`echo x"$CFLAGS" | sed s/-Werror// | sed s/^x//`
> > +AT_COMPILE([[input]])
> 
> You might want to introduce something like this in tests/atconfig.in, or use
> "$O0CFLAGS $WARN_CFLAGS" instead of getting bits of $CFLAGS.

Thanks.

> Other than that, the patches are fine, please install.  (One note though,
> maybe we already debated about this, but I forgot: I prefer to use < and <=
> and not > and >=.  Another lesson I took from Paul Eggert.  Not everybody
> agrees.)

I got that from Paul as well, but sometimes I forget to do it.  Thanks for 
the reminder.

I'll fold in the differences below and push those to master.

I'd also like to cherry pick to branch-2.5 because I think it would be 
nice to release lookahead correction with IELR.  However, yysyntax_error 
on master has already evolved away from branch-2.5, so I first need to 
cherry pick some of your commits from master:

  eeb29 Simplify the i18n of the error messages.
  84eed Pass the token type to yysyntax_error.

I'm not sure I'll find time to port lookahead correction to other 
skeletons before the release of 2.5, so I'm not currently planning to 
search for and cherry pick your corresponding commits for other skeletons.

Does all this sound ok to you?

diff --git a/ChangeLog b/ChangeLog
index 61ba1e1..cc89fde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2009-09-12  Joel E. Denny  <address@hidden>
 
        yacc.c: test yysyntax_error memory management more.
+       * tests/atlocal.in (NO_WERROR_CFLAGS): New cpp macro.
        * tests/regression.at (-Dparse.error=verbose and
        YYSTACK_USE_ALLOCA): New test group.
        (-Dparse.error=verbose overflow): New test group that reveals
diff --git a/tests/atlocal.in b/tests/atlocal.in
index 91ba674..3e33965 100644
--- a/tests/atlocal.in
+++ b/tests/atlocal.in
@@ -10,6 +10,10 @@
 # We want no optimization.
 CFLAGS='@O0CFLAGS@ @WARN_CFLAGS@ @WERROR_CFLAGS@'
 
+# Sometimes a test group needs to ignore gcc warnings, so it locally
+# sets CFLAGS to this.
+NO_WERROR_CFLAGS='@O0CFLAGS@ @WARN_CFLAGS@'
+
 # We need `config.h'.
 CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
 
diff --git a/tests/regression.at b/tests/regression.at
index de91823..a08a9a8 100644
--- a/tests/regression.at
+++ b/tests/regression.at
@@ -1262,7 +1262,7 @@ start: check syntax_error syntax_error ;
 
 check:
 {
-  if (sizeof yymsgbuf > 128)
+  if (128 < sizeof yymsgbuf)
     {
       fprintf (stderr,
                "The initial size of yymsgbuf in yyparse has increased\n"
@@ -1436,7 +1436,7 @@ AT_BISON_CHECK([[-o input.c input.y]])
 # unsigned char.  However, it doesn't produce these same warnings for
 # size_t and many other types when the warnings would seem to make just
 # as much sense.  We ignore the warnings.
-CFLAGS=`echo x"$CFLAGS" | sed s/-Werror// | sed s/^x//`
+CFLAGS="$NO_WERROR_CFLAGS"
 AT_COMPILE([[input]])
 
 AT_PARSER_CHECK([[./input]], [[2]], [],
diff --git a/data/yacc.c b/data/yacc.c
index c98cd55..ea2ae14 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -1452,7 +1452,7 @@ yyerrlab:
         {
           int yysyntax_error_status =
             yysyntax_error (&yymsg_alloc, &yymsg, yystate, yytoken);
-          if (yysyntax_error_status == 2 && yymsg_alloc > 0)
+          if (yysyntax_error_status == 2 && 0 < yymsg_alloc)
             {
               if (yymsg != yymsgbuf)
                 YYSTACK_FREE (yymsg);

reply via email to

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