* [PATCH] Inherit nocast modifier when referencing a variable
@ 2012-10-17 17:12 Lars-Peter Clausen
0 siblings, 0 replies; only message in thread
From: Lars-Peter Clausen @ 2012-10-17 17:12 UTC (permalink / raw)
To: Christopher Li; +Cc: linux-sparse, Lars-Peter Clausen
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2012-10-17 17:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-17 17:12 [PATCH] Inherit nocast modifier when referencing a variable Lars-Peter Clausen
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).