Linux-Sparse Archive on lore.kernel.org
 help / color / Atom feed
From: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
To: linux-sparse@vger.kernel.org
Cc: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Subject: [PATCH 2/4] add another testcase  with const array/pointer
Date: Fri, 10 Jul 2020 02:13:20 +0200
Message-ID: <20200710001322.18391-3-luc.vanoostenryck@gmail.com> (raw)
In-Reply-To: <20200710001322.18391-1-luc.vanoostenryck@gmail.com>

Those are cases that sparse should warn about but doesn't.

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

diff --git a/validation/eval/array-quals1.c b/validation/eval/array-quals1.c
new file mode 100644
index 000000000000..a1c3905826d5
--- /dev/null
+++ b/validation/eval/array-quals1.c
@@ -0,0 +1,50 @@
+typedef const int ci_t;
+typedef       int  ia_t[2];
+typedef const int cia_t[2];
+
+static const int	ci__a[2];
+static ci_t		cit_a[2];
+static const ia_t	c_iat;
+static cia_t		ciat_;
+static cia_t		ciata[2];
+
+static const void *const ok_ci__a = &ci__a;
+static       void *const ko_ci__a = &ci__a;
+static const void *const ok_cit_a = &cit_a;
+static       void *const ko_cit_a = &cit_a;
+static const void *const ok_c_iat = &c_iat;
+static       void *const ko_c_iat = &c_iat;
+static const void *const ok_ciat_ = &ciat_;
+static       void *const ko_ciat_ = &ciat_;
+static const void *const ok_ciata = &ciata;
+static       void *const ko_ciata = &ciata;
+
+static volatile int	vi__a[2];
+static volatile void *const ok_vi__a = &vi__a;
+static          void *const ko_vi__a = &vi__a;
+
+/*
+ * check-name: array-quals1
+ * check-known-to-fail
+ *
+ * check-error-start
+eval/array-quals1.c:12:38: warning: incorrect type in initializer (different modifiers)
+eval/array-quals1.c:12:38:    expected void *static const [toplevel] ko_ci__a
+eval/array-quals1.c:12:38:    got int const ( * )[2]
+eval/array-quals1.c:14:38: warning: incorrect type in initializer (different modifiers)
+eval/array-quals1.c:14:38:    expected void *static const [toplevel] ko_cit_a
+eval/array-quals1.c:14:38:    got int const [usertype] ( * )[2]
+eval/array-quals1.c:16:38: warning: incorrect type in initializer (different modifiers)
+eval/array-quals1.c:16:38:    expected void *static const [toplevel] ko_c_iat
+eval/array-quals1.c:16:38:    got int const ( * )[2]
+eval/array-quals1.c:18:38: warning: incorrect type in initializer (different modifiers)
+eval/array-quals1.c:18:38:    expected void *static const [toplevel] ko_ciat_
+eval/array-quals1.c:18:38:    got int const ( * )[2]
+eval/array-quals1.c:20:38: warning: incorrect type in initializer (different modifiers)
+eval/array-quals1.c:20:38:    expected void *static const [toplevel] ko_ciata
+eval/array-quals1.c:20:38:    got int const [usertype] ( * )[2][2]
+eval/array-quals1.c:24:41: warning: incorrect type in initializer (different modifiers)
+eval/array-quals1.c:24:41:    expected void *static const [toplevel] ko_vi__a
+eval/array-quals1.c:24:41:    got int volatile ( * )[2]
+ * check-error-end
+ */
-- 
2.27.0


  parent reply index

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-10  0:13 [PATCH 0/4] fix evaluation of assignment and qualified arrays Luc Van Oostenryck
2020-07-10  0:13 ` [PATCH 1/4] add a testcase for assignment to const <type> (*)[] Luc Van Oostenryck
2020-07-10  0:13 ` Luc Van Oostenryck [this message]
2020-07-10  0:13 ` [PATCH 3/4] add testcase for missing warning for assignment to const Luc Van Oostenryck
2020-07-10  0:13 ` [PATCH 4/4] [RFC] fix evaluation error with assignment of qualified arrays 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=20200710001322.18391-3-luc.vanoostenryck@gmail.com \
    --to=luc.vanoostenryck@gmail.com \
    --cc=linux-sparse@vger.kernel.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

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