All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH] fix cast to pointer to floating-point
Date: Sat, 11 Mar 2017 15:16:59 +0100	[thread overview]
Message-ID: <20170311141659.36768-1-luc.vanoostenryck@gmail.com> (raw)

By mistake, a cast to floating-pointer pointer was
created as OP_FPCAST instead of OP_PTRCAST.

Fix this by adding the missing 'else'.

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 linearize.c                |  3 +--
 validation/fp-vs-ptrcast.c | 13 +++++++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)
 create mode 100644 validation/fp-vs-ptrcast.c

diff --git a/linearize.c b/linearize.c
index 255231c60..6397f68a7 100644
--- a/linearize.c
+++ b/linearize.c
@@ -1119,8 +1119,7 @@ static struct instruction *alloc_cast_instruction(struct symbol *src, struct sym
 		base = base->ctype.base_type;
 		if (base != &void_ctype)
 			opcode = OP_PTRCAST;
-	}
-	if (base->ctype.base_type == &fp_type)
+	} else if (base->ctype.base_type == &fp_type)
 		opcode = OP_FPCAST;
 	return alloc_typed_instruction(opcode, ctype);
 }
diff --git a/validation/fp-vs-ptrcast.c b/validation/fp-vs-ptrcast.c
new file mode 100644
index 000000000..817aee5c9
--- /dev/null
+++ b/validation/fp-vs-ptrcast.c
@@ -0,0 +1,13 @@
+float *f01(void* p)
+{
+	return p;
+}
+
+/*
+ * check-name: fp-vs-ptrcast
+ * check-command: test-linearize -Wno-decl $file
+ * check-output-ignore
+ *
+ * check-output-excludes: fpcast
+ * check-output-contains: ptrcast
+ */
-- 
2.11.1


             reply	other threads:[~2017-03-11 14:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-11 14:16 Luc Van Oostenryck [this message]
2017-04-25 20:47 ` [PATCH] fix cast to pointer to floating-point Christopher Li

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=20170311141659.36768-1-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.org \
    --cc=sparse@chrisli.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.