linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] testsuite: plain chars are never compatible with [un]signed chars
@ 2020-06-10 20:36 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-06-10 20:36 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

In standard C, plain chars are either signed or unsigned but are only
compatible with themselves, not with signed chars nor with unsigned ones.

However, Sparse has this wrong and make them compatible with the
corresponding sign-qualified chars.

So, add a testcase for this.

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

diff --git a/validation/plain-char-compatibility.c b/validation/plain-char-compatibility.c
new file mode 100644
index 000000000000..cdfe1a31574f
--- /dev/null
+++ b/validation/plain-char-compatibility.c
@@ -0,0 +1,19 @@
+static int sfoo(void)
+{
+	return __builtin_types_compatible_p(char, signed char);
+}
+
+static int ufoo(void)
+{
+	return __builtin_types_compatible_p(char, unsigned char);
+}
+
+/*
+ * check-name: plain-char-compatibility
+ * check-command: test-linearize $file
+ * check-known-to-fail
+ *
+ * check-output-ignore
+ * check-output-pattern(2): ret.*\\$0
+ * check-output-excludes: ret.*\\$1
+ */
-- 
2.27.0

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-10 20:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10 20:36 [PATCH] testsuite: plain chars are never compatible with [un]signed chars Luc Van Oostenryck

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).