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. Current fix is to avoid the evaluation of function call if already set 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@xxxxxxxxx> --- evaluate.c | 4 ++++ validation/eval/undecl-no-indent.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 validation/eval/undecl-no-indent.c diff --git a/evaluate.c b/evaluate.c index 461c2547285f..3b9aec3c13c0 100644 --- a/evaluate.c +++ b/evaluate.c @@ -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 000000000000..4aadf3d99235 --- /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 + */ -- 2.27.0