aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-06-02 18:13:01 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2020-06-12 21:56:31 +0200
commitbb213492a306d68c1254382c254261232981e148 (patch)
tree5b643bed7ff44234ae8c09c4cca5abbd8e9c3ddb
parent42323db3955557b223268ec4196acb77308ab204 (diff)
downloadsparse-bb213492a306d68c1254382c254261232981e148.tar.gz
testsuite: plain chars are never compatible with [un]signed chars
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>
-rw-r--r--validation/plain-char-compatibility.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/validation/plain-char-compatibility.c b/validation/plain-char-compatibility.c
new file mode 100644
index 00000000..cdfe1a31
--- /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
+ */