linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] avoid multiple warnings when inlining undeclared calls
Date: Thu, 25 Jun 2020 21:03:49 +0200	[thread overview]
Message-ID: <20200625190349.3665-1-luc.vanoostenryck@gmail.com> (raw)

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@gmail.com>
---
 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

                 reply	other threads:[~2020-06-25 19:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200625190349.3665-1-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).