diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-04-05 17:38:08 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-06-10 16:10:44 +0200 |
| commit | cb14de58097d97e467dbb97079bebb6ac70038a1 (patch) | |
| tree | 79ccfef0c6107ec0d715f44b382f53e4f639a4b4 /lib.c | |
| parent | ac0636468531f36d47708e121a5c94b6b9d142f7 (diff) | |
| download | sparse-dev-cb14de58097d97e467dbb97079bebb6ac70038a1.tar.gz | |
finer control over error vs. warnings
Currently, once an error is issued, warnings are no more
issued, only others errors are.
It make sense as once an error is encountered things can
be left in an incoherent state and could cause lots of
useless warnings because of this incoherence.
However, it's also quite annoying as even unrelated warnings
are so silenced and potential bugs stay thus hidden.
Fix this by:
- use a specific flag for this: 'has_error'
- make the distinction between the current phase and some previous
phases (but for now we only care about parsing vs evaluation)
- if an error has been issued in a previous phase (at parsing)
warnings are suppressed for the current phase and all future
phases
- if an error is issued in the current phase (evaluation) the
flag is reset after each functions/symbols
For example, with this patch, a typing error in function fa()
will not suppress warnings for function fb(), while a parsing
error will still inhibit all further warnings.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'lib.c')
| -rw-r--r-- | lib.c | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -47,6 +47,7 @@ int verbose, optimize, optimize_size, preprocessing; int die_if_error = 0; +int has_error = 0; #ifndef __GNUC__ # define __GNUC__ 2 @@ -133,7 +134,7 @@ static void do_error(struct position pos, const char * fmt, va_list args) die_if_error = 1; show_info = 1; /* Shut up warnings after an error */ - max_warnings = 0; + has_error |= ERROR_CURR_PHASE; if (errors > 100) { static int once = 0; show_info = 0; @@ -158,7 +159,7 @@ void warning(struct position pos, const char * fmt, ...) return; } - if (!max_warnings) { + if (!max_warnings || has_error) { show_info = 0; return; } @@ -1294,6 +1295,8 @@ struct symbol_list * sparse(char *filename) { struct symbol_list *res = __sparse(filename); + if (has_error & ERROR_CURR_PHASE) + has_error = ERROR_PREV_PHASE; /* Evaluate the complete symbol list */ evaluate_symbol_list(res); |
