mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +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
|
$ 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
|
## make maintainer-check-valgrind
|
||||||
This target uses valgrind both to check bison, and the generated parsers.
|
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
|
glr_stack_item (const glr_stack_item& other) YY_NOEXCEPT YY_NOTHROW
|
||||||
: is_state_ (other.is_state_)]b4_parse_assert_if([[
|
: is_state_ (other.is_state_)]b4_parse_assert_if([[
|
||||||
, magic_ (0xDEAD1ACC)]])[
|
, magic_ (MAGIC)]])[
|
||||||
{]b4_parse_assert_if([[
|
{]b4_parse_assert_if([[
|
||||||
other.check_ ();]])[
|
other.check_ ();]])[
|
||||||
std::memcpy (raw_, other.raw_, union_size);
|
std::memcpy (raw_, other.raw_, union_size);
|
||||||
@@ -1256,7 +1256,9 @@ public:
|
|||||||
check_ ();]])[
|
check_ ();]])[
|
||||||
YYDASSERT (is_state ());
|
YYDASSERT (is_state ());
|
||||||
void *yyp = raw_;
|
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
|
const glr_state& getState () const
|
||||||
@@ -1264,7 +1266,9 @@ public:
|
|||||||
check_ ();]])[
|
check_ ();]])[
|
||||||
YYDASSERT (is_state ());
|
YYDASSERT (is_state ());
|
||||||
const void *yyp = raw_;
|
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 ()
|
semantic_option& getOption ()
|
||||||
@@ -1313,7 +1317,7 @@ public:
|
|||||||
YYASSERT (this->is_state_ == false || this->is_state_ == true);
|
YYASSERT (this->is_state_ == false || this->is_state_ == true);
|
||||||
}
|
}
|
||||||
// A magic number to check our pointer arithmetics is sane.
|
// A magic number to check our pointer arithmetics is sane.
|
||||||
enum { MAGIC = 0xDEAD1ACC };
|
enum { MAGIC = 0xDEAD1ACC }; // 3735886540.
|
||||||
const unsigned int magic_;]])[
|
const unsigned int magic_;]])[
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2349,8 +2353,7 @@ public:
|
|||||||
YYASSERT (yyk.get() == 0);
|
YYASSERT (yyk.get() == 0);
|
||||||
glr_stack_item* yyrhs = yystateStack.firstTop()->asItem();
|
glr_stack_item* yyrhs = yystateStack.firstTop()->asItem();
|
||||||
YY_REDUCE_PRINT ((true, yyrhs, yyk, yyrule, yyparser));
|
YY_REDUCE_PRINT ((true, yyrhs, yyk, yyrule, yyparser));
|
||||||
const YYRESULTTAG res = yyuserAction (yyrule, yynrhs, yyrhs,
|
const YYRESULTTAG res = yyuserAction (yyrule, yynrhs, yyrhs, yyvalp]b4_locations_if([, yylocp])[);
|
||||||
yyvalp]b4_locations_if([, yylocp])[);
|
|
||||||
yystateStack.pop_back(static_cast<size_t>(yynrhs));
|
yystateStack.pop_back(static_cast<size_t>(yynrhs));
|
||||||
yystateStack.setFirstTop(&yystateStack[yystateStack.size() - 1].getState());
|
yystateStack.setFirstTop(&yystateStack[yystateStack.size() - 1].getState());
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user