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'.
This commit is contained in:
Akim Demaille
2019-01-13 10:08:31 +01:00
parent c927c955c8
commit f9db426de6
4 changed files with 25 additions and 27 deletions

View File

@@ -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],