diff options
author | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-09-28 12:39:12 +0200 |
---|---|---|
committer | Reinhold Kainhofer <reinhold@kainhofer.com> | 2011-11-14 22:09:58 +0100 |
commit | c618987255838a2af9813a69eb1f4f20a8df6315 (patch) | |
tree | 40c4d4192900a34ca2667089e8af262220b9e2ed /flower | |
parent | 0722babbea9d5a6b26c4872cbb7ba41ba55cb7bc (diff) |
Warnings: Move all warning-as-error handling to warn.cc
This finally makes that option apply to ALL warnings, and it considerably cleans up the error/warning functions.
Diffstat (limited to 'flower')
-rw-r--r-- | flower/include/warn.hh | 2 | ||||
-rw-r--r-- | flower/warn.cc | 25 |
2 files changed, 17 insertions, 10 deletions
diff --git a/flower/include/warn.hh b/flower/include/warn.hh index f17bef2804..959a556291 100644 --- a/flower/include/warn.hh +++ b/flower/include/warn.hh @@ -41,6 +41,8 @@ #define LOGLEVEL_DEBUG (LOGLEVEL_INFO | LOG_DEBUG) extern int loglevel; +extern bool warning_as_error; + /* output messages, in decreasing order of importance */ void error (string s, string location = ""); // Fatal error, exits lilypond! diff --git a/flower/warn.cc b/flower/warn.cc index af16f20beb..8cdfcb6b99 100644 --- a/flower/warn.cc +++ b/flower/warn.cc @@ -40,6 +40,7 @@ using namespace std; /* Define the loglevel (default is INFO) */ int loglevel = LOGLEVEL_INFO; +bool warning_as_error = false; bool is_loglevel (int level) @@ -188,12 +189,15 @@ error (string s, string location) void programming_error (string s, string location) { - if (is_expected (s)) { + if (is_expected (s)) print_message (LOG_DEBUG, location, _f ("suppressed programming error: %s", s) + "\n"); - } else { - print_message (LOG_ERROR, location, _f ("programming error: %s", s) + "\n"); - print_message (LOG_ERROR, location, _ ("continuing, cross fingers") + "\n"); - } + else if (warning_as_error) + error (s, location); + else + { + print_message (LOG_ERROR, location, _f ("programming error: %s", s) + "\n"); + print_message (LOG_ERROR, location, _ ("continuing, cross fingers") + "\n"); + } } /* Display a non-fatal error message, don't exit. */ @@ -202,9 +206,10 @@ non_fatal_error (string s, string location) { if (is_expected (s)) print_message (LOG_DEBUG, location, _f ("suppressed error: %s", s) + "\n"); - else { + else if (warning_as_error) + error (s, location); + else print_message (LOG_ERROR, location, _f ("error: %s", s) + "\n"); - } } /* Display a warning message. */ @@ -213,10 +218,10 @@ warning (string s, string location) { if (is_expected (s)) print_message (LOG_DEBUG, location, _f ("suppressed warning: %s", s) + "\n"); - else { - // TODO: Add warning-as-error check here + else if (warning_as_error) + error (s, location); + else print_message (LOG_WARN, location, _f ("warning: %s", s) + "\n"); - } } /* Display a success message. */ |