Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] avoid multiple warnings when inlining undeclared calls
@ 2020-06-25 19:03 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-06-25 19:03 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-25 19:03 [PATCH] avoid multiple warnings when inlining undeclared calls Luc Van Oostenryck

Linux-Sparse Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-sparse/0 linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ https://lore.kernel.org/linux-sparse \
		linux-sparse@vger.kernel.org
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-sparse


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git