linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Christopher Li <sparse@chrisli.org>
Cc: linux-sparse@vger.kernel.org, Lars-Peter Clausen <lars@metafoo.de>
Subject: [PATCH] Inherit nocast modifier when referencing  a variable
Date: Wed, 17 Oct 2012 19:12:53 +0200	[thread overview]
Message-ID: <1350493973-6210-1-git-send-email-lars@metafoo.de> (raw)

The nocast modifier should be inherited when referencing a variable, so add it
to MOD_PTRINHERIT.

E.g. without this patch the following code snippet ...

	typedef int __attribute__((nocast)) test_type;

	static void foo(test_type *a) {}

	static void bar(void)
	{
		test_type a;
		foo(&a);
	}

... incorrectly generates the following sparse warnings:

	nocast_ref.c:8:10: warning: incorrect type in argument 1 (different modifiers)
	nocast_ref.c:8:10:    expected int [nocast] [usertype] *a
	nocast_ref.c:8:10:    got int *<noident>
	nocast_ref.c:8:10: warning: implicit cast to nocast type

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 symbol.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/symbol.h b/symbol.h
index 1e74579..c7ec35b 100644
--- a/symbol.h
+++ b/symbol.h
@@ -229,7 +229,8 @@ struct symbol {
 #define MOD_SIZE	(MOD_CHAR | MOD_SHORT | MOD_LONG_ALL)
 #define MOD_IGNORE (MOD_TOPLEVEL | MOD_STORAGE | MOD_ADDRESSABLE |	\
 	MOD_ASSIGNED | MOD_USERTYPE | MOD_ACCESSED | MOD_EXPLICITLY_SIGNED)
-#define MOD_PTRINHERIT (MOD_VOLATILE | MOD_CONST | MOD_NODEREF | MOD_STORAGE | MOD_NORETURN)
+#define MOD_PTRINHERIT (MOD_VOLATILE | MOD_CONST | MOD_NODEREF | MOD_STORAGE | \
+	MOD_NORETURN | MOD_NOCAST)
 
 
 /* Current parsing/evaluation function */
-- 
1.7.10.4


                 reply	other threads:[~2012-10-17 17:18 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=1350493973-6210-1-git-send-email-lars@metafoo.de \
    --to=lars@metafoo.de \
    --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 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).