From b663fd53228e3a27763d3057da08b557b70cf1b9 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Thu, 1 Aug 2013 14:53:54 +0200 Subject: [PATCH 01/13] uniqstr: fix assertion * src/uniqstr.c (uniqstr_assert): Really make sure str is a uniqstr, not just whether some uniqstr with the same content was registered. --- src/uniqstr.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/uniqstr.c b/src/uniqstr.c index 4446c0ed..37345dc7 100644 --- a/src/uniqstr.c +++ b/src/uniqstr.c @@ -77,7 +77,8 @@ uniqstr_vsprintf (char const *format, ...) void uniqstr_assert (char const *str) { - if (!hash_lookup (uniqstrs_table, str)) + uniqstr *s = hash_lookup (uniqstrs_table, str); + if (!s || s != (uniqstr *)str) { error (0, 0, "not a uniqstr: %s", quotearg (str)); From db40c3f869cbee0d02ad5aff4519c72c9476e141 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 1 Aug 2013 16:11:27 +0200 Subject: [PATCH 02/13] tests: minor change to make it easier to test other skeletons * tests/c++.at (Variants): Pass the skeleton as argument. --- tests/c++.at | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/c++.at b/tests/c++.at index 96f2ac1d..e4c527c1 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -174,11 +174,10 @@ AT_CLEANUP m4_pushdef([AT_TEST], [AT_SETUP([Variants $1]) -AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1]) +AT_BISON_OPTION_PUSHDEFS([%debug $1]) # Store strings and integers in a list of strings. AT_DATA_GRAMMAR([list.y], [[%debug -%skeleton "lalr1.cc" %define api.value.type variant ]m4_bpatsubst([$1], [\\n], [ ])[ @@ -320,13 +319,13 @@ AT_BISON_OPTION_POPDEFS AT_CLEANUP ]) -AT_TEST([]) -AT_TEST([%define parse.assert]) -AT_TEST([%locations %define parse.assert]) -AT_TEST([[%define parse.assert %code {\n#define TWO_STAGE_BUILD\n}]]) -AT_TEST([[%define parse.assert %define api.token.constructor]]) -AT_TEST([[%define parse.assert %define api.token.constructor %define api.token.prefix {TOK_}]]) -AT_TEST([[%locations %define parse.assert %define api.token.constructor %define api.token.prefix {TOK_}]]) +AT_TEST([[%skeleton "lalr1.cc" ]]) +AT_TEST([[%skeleton "lalr1.cc" %define parse.assert]]) +AT_TEST([[%skeleton "lalr1.cc" %locations %define parse.assert]]) +AT_TEST([[%skeleton "lalr1.cc" %define parse.assert %code {\n#define TWO_STAGE_BUILD\n}]]) +AT_TEST([[%skeleton "lalr1.cc" %define parse.assert %define api.token.constructor]]) +AT_TEST([[%skeleton "lalr1.cc" %define parse.assert %define api.token.constructor %define api.token.prefix {TOK_}]]) +AT_TEST([[%skeleton "lalr1.cc" %locations %define parse.assert %define api.token.constructor %define api.token.prefix {TOK_}]]) m4_popdef([AT_TEST]) From 1d91bfdf1c8c3e02d8a4eff4fa423673235dd406 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Aug 2013 07:52:27 -0700 Subject: [PATCH 03/13] build: port to pre-5.8.7 perl * examples/local.mk (extract): Omit -f from perl options. This doesn't work with perl versions before 5.8.7 that are configured without USE_SITECUSTOMIZE. Reported by Michael Felt in . --- examples/local.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/local.mk b/examples/local.mk index 05e28e1b..c79c8004 100644 --- a/examples/local.mk +++ b/examples/local.mk @@ -25,7 +25,7 @@ AM_CXXFLAGS = \ doc = $(top_srcdir)/doc/bison.texi extexi = $(top_srcdir)/examples/extexi -extract = VERSION="$(VERSION)" $(PERL) -f $(extexi) $(doc) -- +extract = VERSION="$(VERSION)" $(PERL) $(extexi) $(doc) -- extracted = CLEANFILES += $(extracted) examples/extracted.stamp examples/extracted.stamp: $(doc) $(extexi) From 0149d39e6e5cb4384c07d92c00908d0099d5e009 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Aug 2013 18:00:25 -0700 Subject: [PATCH 04/13] maint: update .gitignore * .gitignore: Add *.eps, *.o, *.pdf, *.png, *.stamp, *~, .deps, .dirstamp. Needed to suppress unwanted chatter from 'git status' after a bootstrap build. --- .gitignore | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index bfb7caf4..e9708d3f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,14 @@ +*.eps +*.o +*.pdf +*.png +*.stamp +*~ +.deps +.dirstamp /*.cache /*.flc /*.prj -/*~ /.tarball-version /.version /ABOUT-NLS From b5e27aa2625c1f84ea1ee75fe74374341664a759 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 24 Aug 2013 18:22:22 -0700 Subject: [PATCH 05/13] build: don't require flex for ordinary builds * configure.ac (LEX): Don't fail if this is lex, as flex is not required for ordinary builds. Instead, issue a warning and substitute a no-op LEX. Reported by Michael Felt in . --- configure.ac | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f7319a15..992e2033 100644 --- a/configure.ac +++ b/configure.ac @@ -175,7 +175,10 @@ AC_SUBST([YACC_LIBRARY]) # Checks for programs. AM_MISSING_PROG([DOT], [dot]) AC_PROG_LEX -$LEX_IS_FLEX || AC_MSG_ERROR([Flex is required]) +$LEX_IS_FLEX || test "X$LEX" = X: || { + AC_MSG_WARN([bypassing lex because flex is required]) + LEX=: +} AC_PROG_YACC AC_PROG_RANLIB AC_PROG_GNU_M4 From 0a244a2269aa09031bf3f92b68fbab4578beec74 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 4 Sep 2013 17:23:37 +0200 Subject: [PATCH 06/13] tests: do not use grep -q Reported by Daniel Galloway. http://lists.gnu.org/archive/html/bug-bison/2013-08/msg00020.html * tests/java.at: Ignore grep's output instead. --- NEWS | 3 +++ THANKS | 1 + tests/java.at | 13 +++++++++---- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 07bf5a9d..bbdcc0f2 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,9 @@ GNU Bison NEWS * Noteworthy changes in release ?.? (????-??-??) [?] +** Bug fixes + + Portability issues in the test suite. * Noteworthy changes in release 3.0 (2013-07-25) [stable] diff --git a/THANKS b/THANKS index 321a8b8a..2d4a6a99 100644 --- a/THANKS +++ b/THANKS @@ -31,6 +31,7 @@ Cris van Pelt cris@amf03054.office.wxs.nl Csaba Raduly csaba_22@yahoo.co.uk Dagobert Michelsen dam@baltic-online.de Daniel Frużyński daniel@poradnik-webmastera.com +Daniel Galloway dg1751@att.com Daniel Hagerty hag@gnu.org David J. MacKenzie djm@gnu.org David Kastrup dak@gnu.org diff --git a/tests/java.at b/tests/java.at index 2b206988..58998fe7 100644 --- a/tests/java.at +++ b/tests/java.at @@ -725,18 +725,23 @@ AT_CLEANUP AT_SETUP([Java constructor init and init_throws]) +m4_pushdef([AT_Witness], +[super("Test Thread"); if (true) throw new InterruptedException();]) + AT_CHECK_JAVA_MINIMAL([[ %define extends {Thread} -%code init { super("Test Thread"); if (true) throw new InterruptedException(); } +%code init { ]AT_Witness[ } %define init_throws {InterruptedException} %lex-param {int lex_param}]]) -AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]]) +AT_CHECK([[grep ']AT_Witness[' YYParser.java]], 0, [ignore]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[ %define extends {Thread} -%code init { super("Test Thread"); if (true) throw new InterruptedException(); } +%code init { ]AT_Witness[ } %define init_throws {InterruptedException}]], [], [[return EOF;]]) -AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]]) +AT_CHECK([[grep ']AT_Witness[' YYParser.java]], 0, [ignore]) + +m4_popdef([AT_Witness]) AT_CLEANUP From 3dc50b3bc2f11909b6edf51ea6e9414228235c2e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 15:51:32 +0200 Subject: [PATCH 07/13] tests: remove stray debugging traces * tests/atlocal.in: Remove traces. Be ready to remove conftest.dSYM generated on OS X. --- tests/atlocal.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/atlocal.in b/tests/atlocal.in index 19ecfd7b..0184ae19 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -72,13 +72,12 @@ int main () std::cout << "Works" << std::endl; } EOF - ls $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS -o conftest conftest.cc case $? in 0);; *) BISON_CXX_WORKS="as_fn_error 77 cannot-compile-simple-program";; esac - rm -f conftest* + rm -fr conftest* fi # Whether the compiler supports POSIXLY_CORRECT defined. From 66b03e134fd851db9de1f57f8fe110799375234e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 15:03:01 +0200 Subject: [PATCH 08/13] variant: remove useless assertion * data/variant.hh (move): Remove precondition assertion which is ensured by the first call of the body (this precondition is also one of "build"). --- data/variant.hh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data/variant.hh b/data/variant.hh index ac4f7a78..19538f6d 100644 --- a/data/variant.hh +++ b/data/variant.hh @@ -178,8 +178,7 @@ m4_define([b4_variant_define], template void move (self_type& other) - {]b4_parse_assert_if([ - YYASSERT (!yytname_);])[ + { build (); swap (other); other.destroy (); From b51cf830a6cb513ca8e357321307997672d6d6b0 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 15:20:22 +0200 Subject: [PATCH 09/13] examples: improve the output of the "variant" example * examples/variant.yy: Improve the printing of lists. --- examples/variant.yy | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/variant.yy b/examples/variant.yy index 9413cbcf..fd551cc1 100644 --- a/examples/variant.yy +++ b/examples/variant.yy @@ -16,7 +16,7 @@ */ %debug -%skeleton "lalr1.cc" +%language "c++" %defines %define api.token.constructor %define api.value.type variant @@ -48,11 +48,17 @@ typedef std::list strings_type; namespace std { std::ostream& - operator<< (std::ostream& o, const strings_type& s) + operator<< (std::ostream& o, const strings_type& ss) { - std::copy (s.begin (), s.end (), - std::ostream_iterator (o, "\n")); - return o; + o << "(" << &ss << ") {"; + const char *sep = ""; + for (strings_type::const_iterator i = ss.begin(), end = ss.end(); + i != end; ++i) + { + o << sep << *i; + sep = ", "; + } + return o << "}"; } } From 3afe18fd1fdc467e6662158275c5d8c3b7121e83 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 14:58:57 +0200 Subject: [PATCH 10/13] glr: better use of tracing macros * data/glr.c (yydestroyGLRState): Use YY_SYMBOL_PRINT instead of yy_symbol_print. --- data/glr.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/data/glr.c b/data/glr.c index ff70890f..bd132333 100644 --- a/data/glr.c +++ b/data/glr.c @@ -836,12 +836,10 @@ yydestroyGLRState (char const *yymsg, yyGLRState *yys]b4_user_formals[) if (yydebug) { if (yys->yysemantics.yyfirstVal) - YYFPRINTF (stderr, "%s unresolved ", yymsg); + YYFPRINTF (stderr, "%s unresolved", yymsg); else - YYFPRINTF (stderr, "%s incomplete ", yymsg); - yy_symbol_print (stderr, yystos[yys->yylrState], - YY_NULL]b4_locuser_args([&yys->yyloc])[); - YYFPRINTF (stderr, "\n"); + YYFPRINTF (stderr, "%s incomplete", yymsg); + YY_SYMBOL_PRINT ("", yystos[yys->yylrState], YY_NULL, &yys->yyloc); } #endif From 9e87ff54729e4d16d61b00b8338a516124ff094d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 15:00:32 +0200 Subject: [PATCH 11/13] glr: formatting changes * data/glr.c: here. --- data/glr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/glr.c b/data/glr.c index bd132333..03a2d078 100644 --- a/data/glr.c +++ b/data/glr.c @@ -1080,7 +1080,7 @@ yyexpandGLRStack (yyGLRStack* yystackp) } if (yystackp->yysplitPoint != YY_NULL) yystackp->yysplitPoint = YYRELOC (yystackp->yyitems, yynewItems, - yystackp->yysplitPoint, yystate); + yystackp->yysplitPoint, yystate); for (yyn = 0; yyn < yystackp->yytops.yysize; yyn += 1) if (yystackp->yytops.yystates[yyn] != YY_NULL) From 5a6e85fb8d223b0decb8fdc10465daf00d2cdf66 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 15:01:24 +0200 Subject: [PATCH 12/13] glr: shorten scopes * data/glr.c (yyglrReduce): Define yyflag with its value. --- data/glr.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/data/glr.c b/data/glr.c index 03a2d078..e30653cc 100644 --- a/data/glr.c +++ b/data/glr.c @@ -1318,11 +1318,10 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule, if (yyforceEval || yystackp->yysplitPoint == YY_NULL) { - YYRESULTTAG yyflag; - YYSTYPE yysval;]b4_locations_if([ - YYLTYPE yyloc;])[ + YYSTYPE yysval;]b4_locations_if([[ + YYLTYPE yyloc;]])[ - yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[); + YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[); if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULL) { YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n", From 77482f2783538f8b5f19970e36a1ace6a93441b3 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 19 Sep 2013 15:27:19 +0200 Subject: [PATCH 13/13] glr: more assertions * data/glr.c (yyaddDeferredAction, yyglrShiftDefer, yypdumpstack): More assertions. --- data/glr.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/data/glr.c b/data/glr.c index e30653cc..8ef35534 100644 --- a/data/glr.c +++ b/data/glr.c @@ -964,6 +964,7 @@ yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate, { yySemanticOption* yynewOption = &yynewGLRStackItem (yystackp, yyfalse)->yyoption; + YYASSERT (!yynewOption->yyisState); yynewOption->yystate = yyrhs; yynewOption->yyrule = yyrule; if (yystackp->yytops.yylookaheadNeeds[yyk]) @@ -1199,6 +1200,7 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState, size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule) { yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate; + YYASSERT (yynewState->yyisState); yynewState->yylrState = yylrState; yynewState->yyposn = yyposn; @@ -2501,6 +2503,8 @@ yypdumpstack (yyGLRStack* yystackp) (unsigned long int) (yyp - yystackp->yyitems)); if (*(yybool *) yyp) { + YYASSERT (yyp->yystate.yyisState); + YYASSERT (yyp->yyoption.yyisState); YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld", yyp->yystate.yyresolved, yyp->yystate.yylrState, (unsigned long int) yyp->yystate.yyposn, @@ -2512,6 +2516,8 @@ yypdumpstack (yyGLRStack* yystackp) } else { + YYASSERT (!yyp->yystate.yyisState); + YYASSERT (!yyp->yyoption.yyisState); YYFPRINTF (stderr, "Option. rule: %d, state: %ld, next: %ld", yyp->yyoption.yyrule - 1, (long int) YYINDEX (yyp->yyoption.yystate),