Allow opt -NDEBUG build to complete without warnings

This commit is contained in:
John Wiegley 2010-06-04 06:02:00 -04:00
parent f16a5382ed
commit b848ace768
11 changed files with 40 additions and 4 deletions

View file

@ -240,14 +240,18 @@ void amount_t::initialize()
// in terms of seconds, but reported as minutes or hours. // in terms of seconds, but reported as minutes or hours.
if (commodity_t * commodity = commodity_pool_t::current_pool->create("s")) if (commodity_t * commodity = commodity_pool_t::current_pool->create("s"))
commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET); commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET);
#if !defined(NO_ASSERTS)
else else
assert(false); assert(false);
#endif
// Add a "percentile" commodity // Add a "percentile" commodity
if (commodity_t * commodity = commodity_pool_t::current_pool->create("%")) if (commodity_t * commodity = commodity_pool_t::current_pool->create("%"))
commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET); commodity->add_flags(COMMODITY_BUILTIN | COMMODITY_NOMARKET);
#if !defined(NO_ASSERTS)
else else
assert(false); assert(false);
#endif
is_initialized = true; is_initialized = true;
} }

View file

@ -155,17 +155,21 @@ public:
result_type calc(scope_t& scope) result_type calc(scope_t& scope)
{ {
if (! compiled) { if (! compiled) {
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) { if (SHOW_DEBUG("expr.compile")) {
DEBUG("expr.compile", "Before compilation:"); DEBUG("expr.compile", "Before compilation:");
dump(*_log_stream); dump(*_log_stream);
} }
#endif // defined(DEBUG_ON)
compile(scope); compile(scope);
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) { if (SHOW_DEBUG("expr.compile")) {
DEBUG("expr.compile", "After compilation:"); DEBUG("expr.compile", "After compilation:");
dump(*_log_stream); dump(*_log_stream);
} }
#endif // defined(DEBUG_ON)
} }
return real_calc(scope); return real_calc(scope);

View file

@ -1166,8 +1166,10 @@ void forecast_posts::flush()
} }
date_t& begin = *(*least).first.start; date_t& begin = *(*least).first.start;
#if !defined(NO_ASSERTS)
if ((*least).first.finish) if ((*least).first.finish)
assert(begin < *(*least).first.finish); assert(begin < *(*least).first.finish);
#endif
// If the next date in the series for this periodic posting is more than 5 // If the next date in the series for this periodic posting is more than 5
// years beyond the last valid post we generated, drop it from further // years beyond the last valid post we generated, drop it from further

View file

@ -391,11 +391,13 @@ global_scope_t::read_command_arguments(scope_t& scope, strings_list args)
void global_scope_t::normalize_session_options() void global_scope_t::normalize_session_options()
{ {
#if defined(LOGGING_ON)
INFO("Initialization file is " << HANDLER(init_file_).str()); INFO("Initialization file is " << HANDLER(init_file_).str());
INFO("Price database is " << session().HANDLER(price_db_).str()); INFO("Price database is " << session().HANDLER(price_db_).str());
foreach (const path& pathname, session().HANDLER(file_).data_files) foreach (const path& pathname, session().HANDLER(file_).data_files)
INFO("Journal file is " << pathname.string()); INFO("Journal file is " << pathname.string());
#endif // defined(LOGGING_ON)
} }
expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope, expr_t::func_t global_scope_t::look_for_precommand(scope_t& scope,

View file

@ -78,10 +78,12 @@ expr_t::ptr_op_t expr_t::op_t::compile(scope_t& scope, const int depth)
// Identifier references are first looked up at the point of // Identifier references are first looked up at the point of
// definition, and then at the point of every use if they could // definition, and then at the point of every use if they could
// not be found there. // not be found there.
#if defined(DEBUG_ON)
if (SHOW_DEBUG("expr.compile")) { if (SHOW_DEBUG("expr.compile")) {
DEBUG("expr.compile", "Found definition:"); DEBUG("expr.compile", "Found definition:");
def->dump(*_log_stream, 0); def->dump(*_log_stream, 0);
} }
#endif // defined(DEBUG_ON)
return copy(def); return copy(def);
} }
else if (left()) { else if (left()) {

View file

@ -61,10 +61,16 @@ class expr_t::parser_t : public noncopyable
return lookahead; return lookahead;
} }
#if !defined(NO_ASSERTS)
void push_token(const token_t& tok) const { void push_token(const token_t& tok) const {
assert(&tok == &lookahead); assert(&tok == &lookahead);
use_lookahead = true; use_lookahead = true;
} }
#else
void push_token(const token_t&) const {
use_lookahead = true;
}
#endif // !defined(NO_ASSERTS)
void push_token() const { void push_token() const {
use_lookahead = true; use_lookahead = true;
} }

View file

@ -115,8 +115,10 @@ struct string_from_python
utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str)); utf8::unchecked::utf16to8(value, value + size, std::back_inserter(str));
else if (sizeof(Py_UNICODE) == 4) // UTF-32 else if (sizeof(Py_UNICODE) == 4) // UTF-32
utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str)); utf8::unchecked::utf32to8(value, value + size, std::back_inserter(str));
#if !defined(NO_ASSERTS)
else else
assert(! "Py_UNICODE has an unexpected size"); assert(! "Py_UNICODE has an unexpected size");
#endif
if (value == 0) throw_error_already_set(); if (value == 0) throw_error_already_set();
void* storage = void* storage =

View file

@ -695,8 +695,10 @@ void instance_t::master_account_directive(char * line)
{ {
if (account_t * acct = context.top_account()->find_account(line)) if (account_t * acct = context.top_account()->find_account(line))
context.state_stack.push_front(acct); context.state_stack.push_front(acct);
#if !defined(NO_ASSERTS)
else else
assert(! "Failed to create account"); assert(! "Failed to create account");
#endif
} }
void instance_t::end_directive(char * kind) void instance_t::end_directive(char * kind)
@ -763,8 +765,12 @@ void instance_t::payee_mapping_directive(char * line)
(payee_mapping_t(mask_t(regex), payee)); (payee_mapping_t(mask_t(regex), payee));
while (peek_whitespace_line()) { while (peek_whitespace_line()) {
#if defined(NO_ASSERTS)
read_line(line);
#else
std::streamsize len = read_line(line); std::streamsize len = read_line(line);
assert(len > 0); assert(len > 0);
#endif
regex = skip_ws(line); regex = skip_ws(line);
if (! *regex) if (! *regex)
@ -786,8 +792,12 @@ void instance_t::account_mapping_directive(char * line)
context.top_account()->find_account(account_name))); context.top_account()->find_account(account_name)));
while (peek_whitespace_line()) { while (peek_whitespace_line()) {
#if defined(NO_ASSERTS)
read_line(line);
#else
std::streamsize len = read_line(line); std::streamsize len = read_line(line);
assert(len > 0); assert(len > 0);
#endif
payee_regex = skip_ws(line); payee_regex = skip_ws(line);
if (! *payee_regex) if (! *payee_regex)

View file

@ -333,10 +333,12 @@ date_t date_specifier_t::begin(const optional_year& current_year) const
month_type the_month = month ? *month : date_t::month_type(1); month_type the_month = month ? *month : date_t::month_type(1);
day_type the_day = day ? *day : date_t::day_type(1); day_type the_day = day ? *day : date_t::day_type(1);
#if !defined(NO_ASSERTS)
if (day) if (day)
assert(! wday); assert(! wday);
else if (wday) else if (wday)
assert(! day); assert(! day);
#endif
// jww (2009-11-16): Handle wday. If a month is set, find the most recent // jww (2009-11-16): Handle wday. If a month is set, find the most recent
// wday in that month; if the year is set, then in that year. // wday in that month; if the year is set, then in that year.

View file

@ -434,8 +434,8 @@ void finish_timer(const char * name);
(SHOW_TRACE(lvl) ? ledger::finish_timer(#name) : ((void)0)) (SHOW_TRACE(lvl) ? ledger::finish_timer(#name) : ((void)0))
#else #else
#define TRACE_START(name, lvl, msg) #define TRACE_START(name, lvl, msg)
#define TRACE_STOP(name) #define TRACE_STOP(name, lvl)
#define TRACE_FINISH(name) #define TRACE_FINISH(name, lvl)
#endif #endif
#if defined(DEBUG_ON) #if defined(DEBUG_ON)
@ -474,8 +474,8 @@ void finish_timer(const char * name);
#else // ! (LOGGING_ON && TIMERS_ON) #else // ! (LOGGING_ON && TIMERS_ON)
#define TRACE_START(lvl, msg, name) #define TRACE_START(lvl, msg, name)
#define TRACE_STOP(name) #define TRACE_STOP(name, lvl)
#define TRACE_FINISH(name) #define TRACE_FINISH(name, lvl)
#define DEBUG_START(name, msg) #define DEBUG_START(name, msg)
#define DEBUG_START_(name, cat, msg) #define DEBUG_START_(name, cat, msg)

View file

@ -62,10 +62,12 @@ xact_base_t::~xact_base_t()
void xact_base_t::add_post(post_t * post) void xact_base_t::add_post(post_t * post)
{ {
#if !defined(NO_ASSERTS)
// You can add temporary postings to transactions, but not real postings to // You can add temporary postings to transactions, but not real postings to
// temporary transactions. // temporary transactions.
if (! post->has_flags(ITEM_TEMP)) if (! post->has_flags(ITEM_TEMP))
assert(! has_flags(ITEM_TEMP)); assert(! has_flags(ITEM_TEMP));
#endif
posts.push_back(post); posts.push_back(post);
} }