mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
glr2.cc: address warnings with G++ 4.8
input.cc: In constructor 'glr_stack_item::glr_stack_item(bool)':
input.cc:1423:5: error: declaration of 'isState' shadows a member of 'this' [-Werror=shadow]
: isState_(isState) {
^
test.cc:1165:45: error: declaration of 'begin' shadows a member of 'this' [-Werror=shadow]
test.cc:1167:45: error: declaration of 'end' shadows a member of 'this' [-Werror=shadow]
* data/skeletons/glr2.cc (isState): Rename as...
(is_state): this.
Formatting changes.
(reduceToOneStack): Rename variables to avoid name clashes.
This commit is contained in:
@@ -818,8 +818,9 @@ static inline int
|
|||||||
yyrhsLength (rule_num yyrule);
|
yyrhsLength (rule_num yyrule);
|
||||||
|
|
||||||
|
|
||||||
class glr_state {
|
class glr_state
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
glr_state()
|
glr_state()
|
||||||
: yyresolved(false)
|
: yyresolved(false)
|
||||||
, yylrState(0)
|
, yylrState(0)
|
||||||
@@ -1195,58 +1196,60 @@ class semantic_option {
|
|||||||
YYLTYPE yyloc;]])[
|
YYLTYPE yyloc;]])[
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Type of the items in the GLR stack. The isState_ field
|
/** Type of the items in the GLR stack. The is_state_ field
|
||||||
* indicates which item of the union is valid. */
|
* indicates which item of the union is valid. */
|
||||||
class glr_stack_item {
|
class glr_stack_item
|
||||||
public:
|
{
|
||||||
glr_stack_item(bool isState = true)
|
public:
|
||||||
: isState_(isState) {
|
glr_stack_item(bool is_state = true)
|
||||||
if (isState) {
|
: is_state_(is_state)
|
||||||
new (&raw_) glr_state;
|
{
|
||||||
} else {
|
if (is_state)
|
||||||
new (&raw_) semantic_option;
|
new (&raw_) glr_state;
|
||||||
}
|
else
|
||||||
|
new (&raw_) semantic_option;
|
||||||
}
|
}
|
||||||
|
|
||||||
glr_stack_item(const glr_stack_item& other) YY_NOEXCEPT YY_NOTHROW
|
glr_stack_item(const glr_stack_item& other) YY_NOEXCEPT YY_NOTHROW
|
||||||
: isState_(other.isState_) {
|
: is_state_(other.is_state_)
|
||||||
|
{
|
||||||
std::memcpy(raw_, other.raw_, union_size);
|
std::memcpy(raw_, other.raw_, union_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
glr_stack_item& operator=(glr_stack_item other)
|
glr_stack_item& operator=(glr_stack_item other)
|
||||||
{
|
{
|
||||||
std::swap(isState_, other.isState_);
|
std::swap(is_state_, other.is_state_);
|
||||||
std::swap(raw_, other.raw_);
|
std::swap(raw_, other.raw_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
~glr_stack_item() {
|
~glr_stack_item()
|
||||||
if (isState()) {
|
{
|
||||||
|
if (is_state())
|
||||||
getState().~glr_state();
|
getState().~glr_state();
|
||||||
} else {
|
else
|
||||||
getOption().~semantic_option();
|
getOption().~semantic_option();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
glr_state& getState() {
|
glr_state& getState() {
|
||||||
YYDASSERT(isState());
|
YYDASSERT(is_state());
|
||||||
return *reinterpret_cast<glr_state*>(&raw_);
|
return *reinterpret_cast<glr_state*>(&raw_);
|
||||||
}
|
}
|
||||||
const glr_state& getState() const {
|
const glr_state& getState() const {
|
||||||
YYDASSERT(isState());
|
YYDASSERT(is_state());
|
||||||
return *reinterpret_cast<const glr_state*>(&raw_);
|
return *reinterpret_cast<const glr_state*>(&raw_);
|
||||||
}
|
}
|
||||||
|
|
||||||
semantic_option& getOption() {
|
semantic_option& getOption() {
|
||||||
YYDASSERT(!isState());
|
YYDASSERT(!is_state());
|
||||||
return *reinterpret_cast<semantic_option*>(&raw_);
|
return *reinterpret_cast<semantic_option*>(&raw_);
|
||||||
}
|
}
|
||||||
const semantic_option& getOption() const {
|
const semantic_option& getOption() const {
|
||||||
YYDASSERT(!isState());
|
YYDASSERT(!is_state());
|
||||||
return *reinterpret_cast<const semantic_option*>(&raw_);
|
return *reinterpret_cast<const semantic_option*>(&raw_);
|
||||||
}
|
}
|
||||||
bool isState() const {
|
bool is_state() const {
|
||||||
return isState_;
|
return is_state_;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
/// The possible contents of raw_. Since they have constructors, they cannot
|
/// The possible contents of raw_. Since they have constructors, they cannot
|
||||||
@@ -1265,7 +1268,7 @@ class glr_stack_item {
|
|||||||
char raw_[union_size];
|
char raw_[union_size];
|
||||||
};
|
};
|
||||||
/** Type tag for the union. */
|
/** Type tag for the union. */
|
||||||
bool isState_;
|
bool is_state_;
|
||||||
};
|
};
|
||||||
|
|
||||||
glr_state* glr_state::pred() {
|
glr_state* glr_state::pred() {
|
||||||
@@ -1409,15 +1412,13 @@ class state_stack {
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
reduceToOneStack() {
|
reduceToOneStack() {
|
||||||
const std::vector<glr_state*>::iterator begin =
|
const std::vector<glr_state*>::iterator yybegin = yytops.begin();
|
||||||
yytops.begin();
|
const std::vector<glr_state*>::iterator yyend = yytops.end();
|
||||||
const std::vector<glr_state*>::iterator end =
|
|
||||||
yytops.end();
|
|
||||||
std::vector<glr_state*>::iterator yyit =
|
std::vector<glr_state*>::iterator yyit =
|
||||||
std::find_if(begin, end, yyGLRStateNotNull);
|
std::find_if(yybegin, yyend, yyGLRStateNotNull);
|
||||||
if (yyit == end)
|
if (yyit == yyend)
|
||||||
return false;
|
return false;
|
||||||
for (state_set_index yyk = create_state_set_index(yyit + 1 - begin);
|
for (state_set_index yyk = create_state_set_index(yyit + 1 - yybegin);
|
||||||
yyk.uget() != numTops(); ++yyk)
|
yyk.uget() != numTops(); ++yyk)
|
||||||
yytops.yymarkStackDeleted (yyk);
|
yytops.yymarkStackDeleted (yyk);
|
||||||
yytops.yyremoveDeletes ();
|
yytops.yyremoveDeletes ();
|
||||||
@@ -1642,7 +1643,7 @@ class state_stack {
|
|||||||
{
|
{
|
||||||
glr_stack_item& item = yyitems[yyi];
|
glr_stack_item& item = yyitems[yyi];
|
||||||
std::cerr << std::setw(3) << yyi << ". ";
|
std::cerr << std::setw(3) << yyi << ". ";
|
||||||
if (item.isState())
|
if (item.is_state())
|
||||||
{
|
{
|
||||||
std::cerr << "Res: " << item.getState().yyresolved
|
std::cerr << "Res: " << item.getState().yyresolved
|
||||||
<< ", LR State: " << item.getState().yylrState
|
<< ", LR State: " << item.getState().yylrState
|
||||||
@@ -1709,14 +1710,14 @@ class state_stack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Return a fresh GLRStackItem in this. The item is an LR state
|
/** Return a fresh GLRStackItem in this. The item is an LR state
|
||||||
* if YYISSTATE, and otherwise a semantic option. Callers should call
|
* if YYIS_STATE, and otherwise a semantic option. Callers should call
|
||||||
* yyreserveStack afterwards to make sure there is sufficient
|
* yyreserveStack afterwards to make sure there is sufficient
|
||||||
* headroom. */
|
* headroom. */
|
||||||
inline size_t
|
inline size_t
|
||||||
yynewGLRStackItem (bool yyisState)
|
yynewGLRStackItem (bool yyis_state)
|
||||||
{
|
{
|
||||||
YYDASSERT(yyitems.size() < yyitems.capacity());
|
YYDASSERT(yyitems.size() < yyitems.capacity());
|
||||||
yyitems.push_back(glr_stack_item(yyisState));
|
yyitems.push_back(glr_stack_item(yyis_state));
|
||||||
return yyitems.size() - 1;
|
return yyitems.size() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user