bug-bison
[Top][All Lists]
Advanced

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

Re: [Bison-Announce] Bison 3.2.90 released [beta]


From: Akim Demaille
Subject: Re: [Bison-Announce] Bison 3.2.90 released [beta]
Date: Sun, 13 Jan 2019 14:08:28 +0100


> Le 13 janv. 2019 à 01:49, Frank Heckenbach <address@hidden> a écrit :
> 
> Akim Demaille wrote:
> 
>> We are very happy to announce the release of Bison 3.2.90, a beta of
>> Bison 3.3.  Please, use it, stress it, and report results.
> 
> I get a new shadowing warning:
> 
> parse.cpp: In member function ‘virtual int TParser::parse()’:
> parse.cpp:1238:53: error: declaration of ‘slice’ shadows a member of 
> ‘TParser’ [-Werror=shadow]
> 
> That's:
> 
>        slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
> 
> parse.h:1790:11: note: shadowed declaration is here
> 
> That's:
> 
>    class slice
> 
> Of course, shadowing is not forbidden by the C++ standard, but since
> it's the only instance of this, you may want to consider renaming
> one of them.

Thanks a lot Frank!

I'm installing this:

commit f9db426de696f5c5593531496ca154361e7b9ce4
Author: Akim Demaille <address@hidden>
Date:   Sun Jan 13 10:08:31 2019 +0100

    c++: beware of -Wshadow
    
    This line:
    
        slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
    
    triggers warnings:
    
        parse.h:1790:11: note: shadowed declaration is here
    
    Reported by Frank Heckenbach.
    http://lists.gnu.org/archive/html/bug-bison/2019-01/msg00002.html
    
    * configure.ac (warn_c): Move -Wshadow to...
    (warn_common): here.
    * data/skeletons/stack.hh (slice): Define as an inner class of stack.
    * data/skeletons/lalr1.cc: Adjust.
    Rename the variable as 'range' instead of 'slice'.

diff --git a/configure.ac b/configure.ac
index 0aa689ea..7fef652d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,8 +96,8 @@ AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test 
"$enable_gcc_warnings" = yes])
 if test "$enable_gcc_warnings" = yes; then
   warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
     -fparse-all-comments -Wdocumentation
-    -Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
-  warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
+    -Wformat -Wnull-dereference -Wpointer-arith -Wshadow -Wwrite-strings'
+  warn_c='-Wbad-function-cast -Wstrict-prototypes'
   warn_cxx='-Wnoexcept'
   # Warnings for the test suite only.
   #
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index d2bb7101..f3ad181c 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -896,8 +896,8 @@ b4_dollar_popdef])[]dnl
 [
       // Default location.
       {
-        slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
-        YYLLOC_DEFAULT (yylhs.location, slice, yylen);
+        stack_type::slice range (yystack_, yylen);
+        YYLLOC_DEFAULT (yylhs.location, range, yylen);
         yyerror_range[1].location = yylhs.location;
       }]])[
 
diff --git a/data/skeletons/stack.hh b/data/skeletons/stack.hh
index ee463494..926a6f8c 100644
--- a/data/skeletons/stack.hh
+++ b/data/skeletons/stack.hh
@@ -122,33 +122,32 @@ m4_define([b4_stack_define],
         return seq_.rend ();
       }
 
+      /// Present a slice of the top of a stack.
+      class slice
+      {
+      public:
+        slice (const stack& stack, int range)
+          : stack_ (stack)
+          , range_ (range)
+        {}
+
+        const T&
+        operator[] (int i) const
+        {
+          return stack_[range_ - i];
+        }
+
+      private:
+        const stack& stack_;
+        int range_;
+      };
+
     private:
       stack (const stack&);
       stack& operator= (const stack&);
       /// The wrapped container.
       S seq_;
     };
-
-    /// Present a slice of the top of a stack.
-    template <typename T, typename S = stack<T> >
-    class slice
-    {
-    public:
-      slice (const S& stack, int range)
-        : stack_ (stack)
-        , range_ (range)
-      {}
-
-      const T&
-      operator[] (int i) const
-      {
-        return stack_[range_ - i];
-      }
-
-    private:
-      const S& stack_;
-      int range_;
-    };
 ]])
 
 m4_ifdef([b4_stack_file],
diff --git a/tests/c++.at b/tests/c++.at
index fe803419..34ec13fb 100644
--- a/tests/c++.at
+++ b/tests/c++.at
@@ -420,8 +420,7 @@ namespace yy
 {
   static
   ]AT_YYLEX_PROTOTYPE[
-  {]AT_LOCATION_IF([
-    typedef parser::location_type location;])[
+  {
     // The 5 is a syntax error whose recovery requires that we discard
     // the lookahead.  This tests a regression, see
     // <http://savannah.gnu.org/support/?108481>.




reply via email to

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