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: Christopher Li <sparse@chrisli.org>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 4/6] testsuite: test modifiers preserved by '&' operator
Date: Thu, 24 Nov 2016 18:09:45 +0100	[thread overview]
Message-ID: <20161124170947.14379-5-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20161124170947.14379-1-luc.vanoostenryck@gmail.com>

Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
---
 validation/ptr-inherit.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 80 insertions(+)
 create mode 100644 validation/ptr-inherit.c

diff --git a/validation/ptr-inherit.c b/validation/ptr-inherit.c
new file mode 100644
index 00000000..58524a71
--- /dev/null
+++ b/validation/ptr-inherit.c
@@ -0,0 +1,80 @@
+#define	__user		__attribute__((address_space(1)))
+#define	__noderef	__attribute__((noderef))
+#define	__bitwise	__attribute__((bitwise))
+#define	__nocast	__attribute__((nocast))
+#define	__safe		__attribute__((safe))
+
+
+/* Should be inherited? */
+static void test_const(void)
+{
+	const int o;
+	int *p = &o;			/* check-should-fail */
+}
+
+static void test_volatile(void)
+{
+	volatile int o;
+	int *p = &o;			/* check-should-fail */
+}
+
+static void test_noderef(void)
+{
+	int __noderef o;
+	int *p = &o;			/* check-should-fail */
+}
+
+static void test_bitwise(void)
+{
+	int __bitwise o;
+	int *p = &o;			/* check-should-fail */
+}
+
+static void test_user(void)
+{
+	int __user o;
+	int *p = &o;			/* check-should-fail */
+}
+
+static void test_nocast(void)
+{
+	int __nocast o;
+	int __nocast *p = &o;		/* check-should-pass */
+}
+
+/* Should be ignored? */
+static void test_static(void)
+{
+	/* storage is not inherited */
+	static int o;
+	int *p = &o;			/* check-should-pass */
+}
+
+static void test_tls(void)
+{
+	/* storage is not inherited */
+	static __thread int o;
+	int *p = &o;			/* check-should-pass */
+}
+
+/*
+ * check-name: ptr-inherit.c
+ *
+ * check-error-start
+ptr-inherit.c:12:19: warning: incorrect type in initializer (different modifiers)
+ptr-inherit.c:12:19:    expected int *p
+ptr-inherit.c:12:19:    got int const *<noident>
+ptr-inherit.c:18:19: warning: incorrect type in initializer (different modifiers)
+ptr-inherit.c:18:19:    expected int *p
+ptr-inherit.c:18:19:    got int volatile *<noident>
+ptr-inherit.c:24:19: warning: incorrect type in initializer (different modifiers)
+ptr-inherit.c:24:19:    expected int *p
+ptr-inherit.c:24:19:    got int [noderef] *<noident>
+ptr-inherit.c:30:19: warning: incorrect type in initializer (different base types)
+ptr-inherit.c:30:19:    expected int *p
+ptr-inherit.c:30:19:    got restricted int *<noident>
+ptr-inherit.c:36:19: warning: incorrect type in initializer (different address spaces)
+ptr-inherit.c:36:19:    expected int *p
+ptr-inherit.c:36:19:    got int <asn:1>*<noident>
+ * check-error-end
+ */
-- 
2.10.2


  parent reply	other threads:[~2016-11-24 17:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-24 17:09 [PATCH 0/6] modifiers inheritance by '&' and 'typeof()' Luc Van Oostenryck
2016-11-24 17:09 ` [PATCH 1/6] storage should not be inherited by pointers Luc Van Oostenryck
2016-11-25  2:09   ` Christopher Li
2016-11-25  3:38     ` Luc Van Oostenryck
2016-11-28  1:04       ` Christopher Li
2016-11-28  2:02         ` Luc Van Oostenryck
2016-11-24 17:09 ` [PATCH 2/6] testsuite: simplify test function-pointer-inheritance Luc Van Oostenryck
2016-11-24 17:09 ` [PATCH 3/6] use a shorter name for function-pointer-modifier-inheritance.c Luc Van Oostenryck
2016-11-24 17:09 ` Luc Van Oostenryck [this message]
2016-11-24 17:09 ` [PATCH 5/6] testsuite: test modifiers preserved by 'typeof()' Luc Van Oostenryck
2016-11-24 17:09 ` [PATCH 6/6] [RFC] some modifiers need to be " Luc Van Oostenryck

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=20161124170947.14379-5-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 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).