mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
glr2.cc: more checks
* data/skeletons/glr2.cc: Clarify use of magic numbers. (glr_stack_item::getState): Check the returned state.
This commit is contained in:
@@ -487,6 +487,16 @@ useful. Here's one way to set ASAN up with GCC 10 on Mac Ports
|
||||
|
||||
$ make check-local TESTSUITEFLAGS='-j5 -k cex' ASAN_OPTIONS=detect_leaks=1
|
||||
|
||||
5. You might need a suppression file. See
|
||||
https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer#suppressions.
|
||||
With G++ on a Mac, you might need a suppression file (say
|
||||
leak.suppression) that contains:
|
||||
|
||||
leak:std::clog
|
||||
|
||||
and pass the additional flags
|
||||
`LSAN_OPTIONS=suppressions=$PWD/leak.suppressions,print_suppressions=0`
|
||||
|
||||
## make maintainer-check-valgrind
|
||||
This target uses valgrind both to check bison, and the generated parsers.
|
||||
|
||||
|
||||
@@ -1215,7 +1215,7 @@ public:
|
||||
|
||||
glr_stack_item (const glr_stack_item& other) YY_NOEXCEPT YY_NOTHROW
|
||||
: is_state_ (other.is_state_)]b4_parse_assert_if([[
|
||||
, magic_ (0xDEAD1ACC)]])[
|
||||
, magic_ (MAGIC)]])[
|
||||
{]b4_parse_assert_if([[
|
||||
other.check_ ();]])[
|
||||
std::memcpy (raw_, other.raw_, union_size);
|
||||
@@ -1256,7 +1256,9 @@ public:
|
||||
check_ ();]])[
|
||||
YYDASSERT (is_state ());
|
||||
void *yyp = raw_;
|
||||
return *static_cast<glr_state*> (yyp);
|
||||
glr_state& res = *static_cast<glr_state*> (yyp);]b4_parse_assert_if([[
|
||||
res.check_ ();]])[
|
||||
return res;
|
||||
}
|
||||
|
||||
const glr_state& getState () const
|
||||
@@ -1264,7 +1266,9 @@ public:
|
||||
check_ ();]])[
|
||||
YYDASSERT (is_state ());
|
||||
const void *yyp = raw_;
|
||||
return *static_cast<const glr_state*> (yyp);
|
||||
const glr_state& res = *static_cast<const glr_state*> (yyp);]b4_parse_assert_if([[
|
||||
res.check_ ();]])[
|
||||
return res;
|
||||
}
|
||||
|
||||
semantic_option& getOption ()
|
||||
@@ -1313,7 +1317,7 @@ public:
|
||||
YYASSERT (this->is_state_ == false || this->is_state_ == true);
|
||||
}
|
||||
// A magic number to check our pointer arithmetics is sane.
|
||||
enum { MAGIC = 0xDEAD1ACC };
|
||||
enum { MAGIC = 0xDEAD1ACC }; // 3735886540.
|
||||
const unsigned int magic_;]])[
|
||||
};
|
||||
|
||||
@@ -2349,8 +2353,7 @@ public:
|
||||
YYASSERT (yyk.get() == 0);
|
||||
glr_stack_item* yyrhs = yystateStack.firstTop()->asItem();
|
||||
YY_REDUCE_PRINT ((true, yyrhs, yyk, yyrule, yyparser));
|
||||
const YYRESULTTAG res = yyuserAction (yyrule, yynrhs, yyrhs,
|
||||
yyvalp]b4_locations_if([, yylocp])[);
|
||||
const YYRESULTTAG res = yyuserAction (yyrule, yynrhs, yyrhs, yyvalp]b4_locations_if([, yylocp])[);
|
||||
yystateStack.pop_back(static_cast<size_t>(yynrhs));
|
||||
yystateStack.setFirstTop(&yystateStack[yystateStack.size() - 1].getState());
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user