mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
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:
@@ -96,8 +96,8 @@ AM_CONDITIONAL([ENABLE_GCC_WARNINGS], [test "$enable_gcc_warnings" = yes])
|
|||||||
if test "$enable_gcc_warnings" = yes; then
|
if test "$enable_gcc_warnings" = yes; then
|
||||||
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
|
warn_common='-Wall -Wextra -Wno-sign-compare -Wcast-align
|
||||||
-fparse-all-comments -Wdocumentation
|
-fparse-all-comments -Wdocumentation
|
||||||
-Wformat -Wnull-dereference -Wpointer-arith -Wwrite-strings'
|
-Wformat -Wnull-dereference -Wpointer-arith -Wshadow -Wwrite-strings'
|
||||||
warn_c='-Wbad-function-cast -Wshadow -Wstrict-prototypes'
|
warn_c='-Wbad-function-cast -Wstrict-prototypes'
|
||||||
warn_cxx='-Wnoexcept'
|
warn_cxx='-Wnoexcept'
|
||||||
# Warnings for the test suite only.
|
# Warnings for the test suite only.
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -896,8 +896,8 @@ b4_dollar_popdef])[]dnl
|
|||||||
[
|
[
|
||||||
// Default location.
|
// Default location.
|
||||||
{
|
{
|
||||||
slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
|
stack_type::slice range (yystack_, yylen);
|
||||||
YYLLOC_DEFAULT (yylhs.location, slice, yylen);
|
YYLLOC_DEFAULT (yylhs.location, range, yylen);
|
||||||
yyerror_range[1].location = yylhs.location;
|
yyerror_range[1].location = yylhs.location;
|
||||||
}]])[
|
}]])[
|
||||||
|
|
||||||
|
|||||||
@@ -122,33 +122,32 @@ m4_define([b4_stack_define],
|
|||||||
return seq_.rend ();
|
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:
|
private:
|
||||||
stack (const stack&);
|
stack (const stack&);
|
||||||
stack& operator= (const stack&);
|
stack& operator= (const stack&);
|
||||||
/// The wrapped container.
|
/// The wrapped container.
|
||||||
S seq_;
|
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],
|
m4_ifdef([b4_stack_file],
|
||||||
|
|||||||
@@ -420,8 +420,7 @@ namespace yy
|
|||||||
{
|
{
|
||||||
static
|
static
|
||||||
]AT_YYLEX_PROTOTYPE[
|
]AT_YYLEX_PROTOTYPE[
|
||||||
{]AT_LOCATION_IF([
|
{
|
||||||
typedef parser::location_type location;])[
|
|
||||||
// The 5 is a syntax error whose recovery requires that we discard
|
// The 5 is a syntax error whose recovery requires that we discard
|
||||||
// the lookahead. This tests a regression, see
|
// the lookahead. This tests a regression, see
|
||||||
// <http://savannah.gnu.org/support/?108481>.
|
// <http://savannah.gnu.org/support/?108481>.
|
||||||
|
|||||||
Reference in New Issue
Block a user