mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
lalr1.cc: modern C++ no longer needs an assignment for symbols
Reported by Frank Heckenbach. http://lists.gnu.org/archive/html/bug-bison/2018-03/msg00002.html Actually the assignment operator should never be needed: the C++98 requirements for vector::push_back is CopyInsertable, which does not require an assignment operator. However, libstdc++ shipped with GCC up to (and including) 6 uses the assignment operator (which affects Clang on top of libstdc++, but also ICC). So let's keep it for legacy C++. See https://gcc.godbolt.org/z/q0XXmC. * data/lalr1.cc (stack_symbol_type::operator=): Remove. * data/c++.m4 (basic_symbol::operator=): Ditto. * tests/c++.at (C++ Variant-based Symbols Unit Tests): Adjust.
This commit is contained in:
@@ -272,8 +272,10 @@ m4_define([b4_symbol_type_declare],
|
|||||||
location_type location;])[
|
location_type location;])[
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
#if defined __cplusplus && __cplusplus < 201103L
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
basic_symbol& operator= (const basic_symbol& other);
|
basic_symbol& operator= (const basic_symbol& other);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Type access provider for token (enum) based symbols.
|
/// Type access provider for token (enum) based symbols.
|
||||||
|
|||||||
@@ -326,8 +326,10 @@ b4_location_define])])[
|
|||||||
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
|
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
|
||||||
/// Steal the contents from \a sym to build this.
|
/// Steal the contents from \a sym to build this.
|
||||||
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
|
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
|
||||||
/// Assignment, needed by push_back.
|
#if defined __cplusplus && __cplusplus < 201103L
|
||||||
|
/// Assignment, needed by push_back by some old implementations.
|
||||||
stack_symbol_type& operator= (YY_MOVE_REF (stack_symbol_type) that);
|
stack_symbol_type& operator= (YY_MOVE_REF (stack_symbol_type) that);
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Stack type.
|
/// Stack type.
|
||||||
@@ -608,6 +610,7 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
that.type = empty_symbol;
|
that.type = empty_symbol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined __cplusplus && __cplusplus < 201103L
|
||||||
]b4_parser_class_name[::stack_symbol_type&
|
]b4_parser_class_name[::stack_symbol_type&
|
||||||
]b4_parser_class_name[::stack_symbol_type::operator= (YY_MOVE_REF (stack_symbol_type) that)
|
]b4_parser_class_name[::stack_symbol_type::operator= (YY_MOVE_REF (stack_symbol_type) that)
|
||||||
{
|
{
|
||||||
@@ -618,6 +621,7 @@ m4_if(b4_prefix, [yy], [],
|
|||||||
location = YY_MOVE (that.location);])[
|
location = YY_MOVE (that.location);])[
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
template <typename Base>
|
template <typename Base>
|
||||||
void
|
void
|
||||||
|
|||||||
@@ -166,12 +166,12 @@ int main()
|
|||||||
for (int i = 0; i < 100; ++i)
|
for (int i = 0; i < 100; ++i)
|
||||||
{
|
{
|
||||||
#if defined __cplusplus && 201103L <= __cplusplus
|
#if defined __cplusplus && 201103L <= __cplusplus
|
||||||
auto ss = parser::stack_symbol_type(1, parser::make_INT(123));
|
st.push(parser::stack_symbol_type{1, parser::make_INT(123)});
|
||||||
#else
|
#else
|
||||||
parser::symbol_type s = parser::make_INT(123);
|
parser::symbol_type s = parser::make_INT(123);
|
||||||
parser::stack_symbol_type ss(1, s);
|
parser::stack_symbol_type ss(1, s);
|
||||||
#endif
|
|
||||||
st.push(ss);
|
st.push(ss);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user