work around bison 3.2 bug (fixes #72)

This commit is contained in:
Wolfgang Thaller 2018-12-23 12:02:36 +01:00
parent 00471c6104
commit 7eced7335a
2 changed files with 34 additions and 1 deletions

View File

@ -118,7 +118,18 @@
{
public:
RezSymbol() = default;
RezSymbol(yy::RezParser::symbol_type&& x) : yy::RezParser::symbol_type(std::move(x)) {}
// Bison 3.2 has a bug in the move constructor for basic_symbol<by_type>.
// Bison-generated code uses only basic_symbol<by_type>::move, which
// works without crashing.
RezSymbol(yy::RezParser::symbol_type&& x)
{
move(x);
}
RezSymbol(RezSymbol&& x)
{
move(x);
}
};
}

View File

@ -25,6 +25,28 @@ BOOST_AUTO_TEST_SUITE(LexSuite)
BOOST_CHECK_EQUAL(t.token(), TOKEN); \
} while(0)
BOOST_AUTO_TEST_CASE(moveBisonSymbol)
{
// Bison 3.2 contains a bug in the move constructor for its symbol type.
// It will crash when used.
// Unfortunately, there is no copy constructor any more, so it's hard to avoid.
std::string filename = "foo";
yy::location loc(&filename, 0,0);
auto sym = RezParser::make_INTLIT(42, loc);
auto sym2 = std::move(sym);
}
BOOST_AUTO_TEST_CASE(moveRezSymbol)
{
// This tests my workaround for the bison bug;
// RezSymbol derives from bison's symbol type and reimplements all move constructors
std::string filename = "foo";
yy::location loc(&filename, 0,0);
RezSymbol sym = RezParser::make_INTLIT(42, loc);
auto sym2 = std::move(sym);
}
BOOST_AUTO_TEST_CASE(basicInt)
{
RezWorld world;