mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
lalr1.cc: fix stack symbol move
In some casing, once we moved a stack symbol, we forget to mark the source stack symbol as emptied. As a consequence, it may be destroyed a second time. This happens when the stack has to be resized. * data/lalr1.cc (stack_symbol_type::stack_symbol_type): Record that the source was emptied. (stack_symbol_type::operator=): Likewise. * tests/c++.at (C++ Variant-based Symbols Unit Tests): Force the stack to be resized. Check its content.
This commit is contained in:
20
tests/c++.at
20
tests/c++.at
@@ -162,19 +162,27 @@ int main()
|
||||
std::cerr << ss.value.as<int>() << '\n';
|
||||
}
|
||||
|
||||
// pushing on the stack.
|
||||
// Pushing on the stack.
|
||||
// Sufficiently many so that it will be resized.
|
||||
// Probably 3 times (starting at 200).
|
||||
{
|
||||
parser::stack_type st;
|
||||
for (int i = 0; i < 100; ++i)
|
||||
const int mucho = 1700;
|
||||
for (int i = 0; i < mucho; ++i)
|
||||
{
|
||||
#if defined __cplusplus && 201103L <= __cplusplus
|
||||
st.push(parser::stack_symbol_type{1, parser::make_INT(123)});
|
||||
st.push(parser::stack_symbol_type{1, parser::make_INT (i)});
|
||||
#else
|
||||
parser::symbol_type s = parser::make_INT(123);
|
||||
parser::stack_symbol_type ss(1, s);
|
||||
st.push(ss);
|
||||
parser::symbol_type s = parser::make_INT (i);
|
||||
parser::stack_symbol_type ss (1, s);
|
||||
st.push (ss);
|
||||
#endif
|
||||
}
|
||||
for (int i = mucho - 1; 0 <= i; --i)
|
||||
{
|
||||
assert (st[0].value.as<int>() == i);
|
||||
st.pop ();
|
||||
}
|
||||
}
|
||||
}
|
||||
]])
|
||||
|
||||
Reference in New Issue
Block a user