diff options
author | 2007-02-27 13:15:59 -0800 | |
---|---|---|
committer | 2007-02-27 16:22:48 -0800 | |
commit | d4ae1cacb43461358a9b1f229f26c85c2456ff7e (patch) | |
tree | 4070abbecba4f93331ff7eb57b31d6e4e3dc3c3b /lib.c | |
parent | Update the information in README about using the library. (diff) | |
download | sparse-d4ae1cacb43461358a9b1f229f26c85c2456ff7e.tar.gz sparse-d4ae1cacb43461358a9b1f229f26c85c2456ff7e.tar.bz2 sparse-d4ae1cacb43461358a9b1f229f26c85c2456ff7e.zip |
Introduce expression_error
Add a new function expression_error, which works just like
sparse_error but also installs a bad_ctype into the expression.
Signed-Off-By: Christopher Li <sparse@chrisli.org>
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -126,10 +126,9 @@ void warning(struct position pos, const char * fmt, ...) va_end(args); } -void sparse_error(struct position pos, const char * fmt, ...) +void do_error(struct position pos, const char * fmt, va_list args) { static int errors = 0; - va_list args; die_if_error = 1; show_info = 1; /* Shut up warnings after an error */ @@ -143,12 +142,27 @@ void sparse_error(struct position pos, const char * fmt, ...) once = 1; } - va_start(args, fmt); do_warn("error: ", pos, fmt, args); - va_end(args); errors++; } +void sparse_error(struct position pos, const char * fmt, ...) +{ + va_list args; + va_start(args, fmt); + do_error(pos, fmt, args); + va_end(args); +} + +void expression_error(struct expression *expr, const char *fmt, ...) +{ + va_list args; + va_start(args, fmt); + do_error(expr->pos, fmt, args); + va_end(args); + expr->ctype = &bad_ctype; +} + void error_die(struct position pos, const char * fmt, ...) { va_list args; |