diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-06-25 18:07:18 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-07-04 12:14:26 +0200 |
commit | 79a6ae8316377e6b2c043c4d37ed704d86770c3c (patch) | |
tree | 27c083475939cb866e2206b9fae0bc2f45bbd68b | |
parent | fa15396204a796135f71b5aef6cbbe3ba1fc0eb3 (diff) | |
download | sparse-79a6ae8316377e6b2c043c4d37ed704d86770c3c.tar.gz |
avoid multiple warnings when inlining undeclared calls
When inlining multiple times a function which contains an undeclared
function call, multiple error messages are issued. More annoyingly,
only the first one is meaningful, the other ones doesn't even show
the incriminated identifier:
error: undefined identifier '...'
error: not a function <noident>
Part of the problem is that the first message is displayed with
expression_error() which also sets the expression to &bad_ctype.
This change the way how the expression is handled when re-evaluated.
Fix this by avoiding the evaluation of function calls that already
evaluate to bad_ctype: it's known that an error message have already
been issued for them and that nothing good can done with them.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | evaluate.c | 4 | ||||
-rw-r--r-- | validation/eval/undecl-no-indent.c | 19 |
2 files changed, 23 insertions, 0 deletions
@@ -3130,6 +3130,10 @@ static struct symbol *evaluate_call(struct expression *expr) if (ctype->type != SYM_FN) { struct expression *arg; + + if (fn->ctype == &bad_ctype) + return NULL; + expression_error(expr, "not a function %s", show_ident(sym->ident)); /* do typechecking in arguments */ diff --git a/validation/eval/undecl-no-indent.c b/validation/eval/undecl-no-indent.c new file mode 100644 index 00000000..4aadf3d9 --- /dev/null +++ b/validation/eval/undecl-no-indent.c @@ -0,0 +1,19 @@ +inline void fun(void) +{ + undecl(); +} + +void foo(void); +void foo(void) +{ + fun(); + fun(); +} + +/* + * check-name: undecl-no-indent + * + * check-error-start +eval/undecl-no-indent.c:3:9: error: undefined identifier 'undecl' + * check-error-end + */ |