[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: temporary workaround for current test failures in lalr1.cc
From: |
Akim Demaille |
Subject: |
Re: temporary workaround for current test failures in lalr1.cc |
Date: |
Thu, 16 Dec 2004 15:39:44 +0100 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) |
>>> "Akim" == Akim Demaille <address@hidden> writes:
> I'm puzzled. It depends on the version of G++, but valgrind sees
> nothing suspicious. I'll dig.
It also depended on with or without -O2, as do many similar bugs. It
turned out that we were reading beyond yycheck's size. And then I
remembered there were patches applied to glr and yacc for this
problem, I only had to port them.
Index: ChangeLog
from Akim Demaille <address@hidden>
* data/lalr1.cc (yyreport_syntax_error_): Catch up with glr.c and
yacc.c: be sure to stay within yycheck_.
* tests/actions.at: Re-enable C++ tests.
Index: data/lalr1.cc
===================================================================
RCS file: /cvsroot/bison/bison/data/lalr1.cc,v
retrieving revision 1.71
diff -u -u -r1.71 lalr1.cc
--- data/lalr1.cc 16 Dec 2004 09:06:08 -0000 1.71
+++ data/lalr1.cc 16 Dec 2004 14:28:33 -0000
@@ -810,24 +810,30 @@
yyn_ = yypact_[yystate_];
if (yypact_ninf_ < yyn_ && yyn_ < yylast_)
{
+ /* Start YYX at -YYN if negative to avoid negative indexes in
+ YYCHECK. */
+ int yyxbegin = yyn_ < 0 ? -yyn_ : 0;
+
+ /* Stay within bounds of both yycheck and yytname. */
+ int yychecklim = yylast_ - yyn_;
+ int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
+ int count = 0;
+ for (int x = yyxbegin; x < yyxend; ++x)
+ if (yycheck_[x + yyn_] == x && x != yyterror_)
+ ++count;
+
message = "syntax error, unexpected ";
message += yyname_[yyilooka_];
- {
- int count = 0;
- for (int x = (yyn_ < 0 ? -yyn_ : 0); x < yyntokens_ + yynnts_; ++x)
- if (yycheck_[x + yyn_] == x && x != yyterror_)
- ++count;
- if (count < 5)
- {
- count = 0;
- for (int x = (yyn_ < 0 ? -yyn_ : 0); x < yyntokens_ + yynnts_;
++x)
- if (yycheck_[x + yyn_] == x && x != yyterror_)
- {
- message += (!count++) ? ", expecting " : " or ";
- message += yyname_[x];
- }
- }
- }
+ if (count < 5)
+ {
+ count = 0;
+ for (int x = yyxbegin; x < yyxend; ++x)
+ if (yycheck_[x + yyn_] == x && x != yyterror_)
+ {
+ message += (!count++) ? ", expecting " : " or ";
+ message += yyname_[x];
+ }
+ }
}
else
#endif
Index: tests/actions.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/actions.at,v
retrieving revision 1.44
diff -u -u -r1.44 actions.at
--- tests/actions.at 15 Dec 2004 16:18:11 -0000 1.44
+++ tests/actions.at 16 Dec 2004 14:28:33 -0000
@@ -468,10 +468,8 @@
# These tests currently fail on a Debian GNU/Linux 3.0r2 x86 host,
# but the 2nd test succeeds on a Solaris 9 sparc hosts (Forte 7 cc).
# Skip them until we figure out what the problem is.
-AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], ,
- [AT_CHECK([exit 77])])
-AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [with union],
- [AT_CHECK([exit 77])])
+AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"])
+AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [with union])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser])
AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union])