mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 09:13:04 +00:00
Fix glr.cc and lalr1.cc's use of YYDEBUG so that there's zero
runtime cost when YYDEBUG is not defined, and so that some tests that used to fail now work. Problem and initial suggestion by Paolo Bonzini. * data/c++.m4 (b4_parse_param_cons): Omit leading ','. * data/glr.cc (b4_parser_class_name): Initialize yycdebug_ only if YYDEBUG. Also, initialize yydebug_. (debug_level, set_debug_level): Affect yydebug_, not ::yydebug. (yydebug_) [YYDEBUG]: New member. (yycdebug_): Now defined only if YYDEBUG. * data/lalr1.cc (yydebug_, yycdebug_): Now defined only if YYDEBUG. (YYCDEBUG) [!YYDEBUG]: Don't use yydebug_ and yycdebug_. (b4_parser_class_name): Initialize yydebug_ and yycdebug_ only if YYYDEBUG. (debug_stream, set_debug_stream, debug_level, set_debug_level): Define only if YYDEBUG. * tests/calc.at (_AT_DATA_CALC_Y) [!YYDEBUG]: Omit call to set_debug_level. * tests/regression.at (_AT_DATA_DANCER_Y) [!YYDEBUG]: Likewise. * tests/calc.at (AT_CHECK_CALC_GLR_CC): Uncomment calls to AT_CHECK_CALC_GLR_CC that are working now.
This commit is contained in:
21
data/glr.cc
21
data/glr.cc
@@ -122,8 +122,12 @@ namespace ]b4_namespace[
|
||||
]dnl In this section, the parse param are the original parse_params.
|
||||
m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
[ /// Build a parser object.
|
||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)
|
||||
: yycdebug_ (&std::cerr)]b4_parse_param_cons[
|
||||
]b4_parser_class_name::b4_parser_class_name[ (]b4_parse_param_decl[)]m4_ifset([b4_parse_param], [
|
||||
:])[
|
||||
#if YYDEBUG
|
||||
]m4_ifset([b4_parse_param], [ ], [ :])[yydebug_ (false),
|
||||
yycdebug_ (&std::cerr)]m4_ifset([b4_parse_param], [,])[
|
||||
#endif]b4_parse_param_cons[
|
||||
{
|
||||
}
|
||||
|
||||
@@ -185,16 +189,16 @@ m4_pushdef([b4_parse_param], m4_defn([b4_parse_param_orig]))dnl
|
||||
]b4_parser_class_name[::debug_level_type
|
||||
]b4_parser_class_name[::debug_level () const
|
||||
{
|
||||
return ::yydebug;
|
||||
return yydebug_;
|
||||
}
|
||||
|
||||
void
|
||||
]b4_parser_class_name[::set_debug_level (debug_level_type l)
|
||||
{
|
||||
::yydebug = l;
|
||||
yydebug_ = l;
|
||||
}
|
||||
|
||||
#endif /* ! YYDEBUG */
|
||||
#endif
|
||||
]m4_popdef([b4_parse_param])dnl
|
||||
[} // namespace ]b4_namespace[
|
||||
|
||||
@@ -337,7 +341,10 @@ b4_user_stype
|
||||
const semantic_type* yyvaluep,
|
||||
const location_type* yylocationp);
|
||||
private:
|
||||
#endif /* ! YYDEBUG */
|
||||
/* Debugging. */
|
||||
int yydebug_;
|
||||
std::ostream* yycdebug_;
|
||||
#endif
|
||||
|
||||
|
||||
/// \brief Reclaim the memory associated to a symbol.
|
||||
@@ -350,8 +357,6 @@ b4_user_stype
|
||||
semantic_type* yyvaluep,
|
||||
location_type* yylocationp);
|
||||
|
||||
/* Debugging. */
|
||||
std::ostream* yycdebug_;
|
||||
]b4_parse_param_vars[
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user