Hi Jim, On Sat, 16 Apr 2011, Jim Meyering wrote:
> I've just bootstrapped, configured with --enable-gcc-warnings, built > and run "make check" on Fedora 15 (i.e., gcc version 4.6.0 20110413) > I was surprised to see so many failures (abbreviated output below). > > However, they're all due to one newly-enabled gcc warning: > note the [-Werror=unused-but-set-variable] in every case below. Thanks for the report. In all but one case, that warning is revealing an old bug in glr.c. In the remaining case, it's suprious but easy to suppress. I pushed the fixes below to master and branch-2.5. > At first I tried to turn off only that one new warning, > but -Wno-unused-but-set-variable had no effect, so I > resorted to -Wno-unused. In case it helps, either of those worked for me. >From 55dd35633675f588c58ead46ecd6b5f4db504192 Mon Sep 17 00:00:00 2001 From: Joel E. Denny <[email protected]> Date: Sat, 16 Apr 2011 18:15:40 -0400 Subject: [PATCH 1/2] glr.c: omit yyresolveLocations when locations are disabled. This prevents gcc 4.6.0's -Wunused-but-set-variable from warning about yyresolveLocations's local yyrhsloc. When locations are enabled, there's no such warning because YYLLOC_DEFAULT then uses yyrhsloc. Reported by Jim Meyering at <http://lists.gnu.org/archive/html/bug-bison/2011-04/msg00002.html>. * data/glr.c (yyresolveLocations): Omit definition when locations are disabled. (yyresolveValue): Omit yyresolveLocations invocation when locations are disabled. --- ChangeLog | 13 +++++++++++++ data/glr.c | 8 ++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 70ee004..4c63cb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2011-04-16 Joel E. Denny <[email protected]> + glr.c: omit yyresolveLocations when locations are disabled. + This prevents gcc 4.6.0's -Wunused-but-set-variable from warning + about yyresolveLocations's local yyrhsloc. When locations are + enabled, there's no such warning because YYLLOC_DEFAULT then uses + yyrhsloc. Reported by Jim Meyering at + <http://lists.gnu.org/archive/html/bug-bison/2011-04/msg00002.html>. + * data/glr.c (yyresolveLocations): Omit definition when locations + are disabled. + (yyresolveValue): Omit yyresolveLocations invocation when + locations are disabled. + +2011-04-16 Joel E. Denny <[email protected]> + gnulib, autoconf: update. * README-hacking (Updating a submodule): Give advice on how to determine the versions of gnulib and autoconf to which we should diff --git a/data/glr.c b/data/glr.c index 6829ca3..df90201 100644 --- a/data/glr.c +++ b/data/glr.c @@ -1802,7 +1802,7 @@ yyreportAmbiguity (yySemanticOption* yyx0, yyerror (]b4_yyerror_args[YY_("syntax is ambiguous")); return yyabort; -} +}]b4_locations_if([[ /** Starting at and including state S1, resolve the location for each of the * previous N1 states that is unresolved. The first semantic option of a state @@ -1860,7 +1860,7 @@ yyresolveLocations (yyGLRState* yys1, int yyn1, yylloc = yylloc_current; } } -} +}]])[ /** Resolve the ambiguity represented in state S, perform the indicated * actions, and set the semantic value of S. If result != yyok, the chain of @@ -1894,8 +1894,8 @@ yyresolveValue (yyGLRState* yys, yyGLRStack* yystackp]b4_user_formals[) { switch (yypreference (yybest, yyp)) { - case 0: - yyresolveLocations (yys, 1, yystackp]b4_user_args[); + case 0:]b4_locations_if([[ + yyresolveLocations (yys, 1, yystackp]b4_user_args[);]])[ return yyreportAmbiguity (yybest, yyp]b4_pure_args[); break; case 1: -- 1.7.0.4 >From c9e2da4f20c97c4cb53b68d4912dbdb8836df9a4 Mon Sep 17 00:00:00 2001 From: Joel E. Denny <[email protected]> Date: Sat, 16 Apr 2011 18:26:18 -0400 Subject: [PATCH 2/2] tests: pacify gcc 4.6.0's -Wunused-but-set-variable. Reported by Jim Meyering at <http://lists.gnu.org/archive/html/bug-bison/2011-04/msg00002.html>. * tests/actions.at (Default %printer and %destructor for mid-rule values): Define YYLLOC_DEFAULT so that it uses its Rhs argument. --- ChangeLog | 9 +++++++++ tests/actions.at | 2 +- 2 files changed, 10 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c63cb1..243ee1f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-04-16 Joel E. Denny <[email protected]> + tests: pacify gcc 4.6.0's -Wunused-but-set-variable. + Reported by Jim Meyering at + <http://lists.gnu.org/archive/html/bug-bison/2011-04/msg00002.html>. + * tests/actions.at + (Default %printer and %destructor for mid-rule values): Define + YYLLOC_DEFAULT so that it uses its Rhs argument. + +2011-04-16 Joel E. Denny <[email protected]> + glr.c: omit yyresolveLocations when locations are disabled. This prevents gcc 4.6.0's -Wunused-but-set-variable from warning about yyresolveLocations's local yyrhsloc. When locations are diff --git a/tests/actions.at b/tests/actions.at index 3761650..c95038e 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1199,7 +1199,7 @@ AT_DATA_GRAMMAR([[input.y]], static int yylex (void); # define USE(SYM) # define YYLTYPE int -# define YYLLOC_DEFAULT(Current, Rhs, N) +# define YYLLOC_DEFAULT(Current, Rhs, N) (void)(Rhs) # define YY_LOCATION_PRINT(File, Loc) %} -- 1.7.0.4
