aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/validation
diff options
authorLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-05-29 00:29:46 +0200
committerLuc Van Oostenryck <luc.vanoostenryck@gmail.com>2017-12-29 22:42:45 +0100
commitd1ad9561e9cd43373f692394567f627230a511d1 (patch)
treea8017d22f5c1a75edee3f03f556a26fb1e76047c /validation
parent95ae484069ebcf6d2d1f754451f898b0f23d3211 (diff)
downloadsparse-dev-d1ad9561e9cd43373f692394567f627230a511d1.tar.gz
add support for '-f[no-][un]signed-char'
Till now, sparse's plain chars where signed with no possibility to change it. This is a problem when using sparse on code for architectures like ARM where chars are by default unsigned or simply for code compiled with GCC's '-f[no-][un]signed-char'. Change this by parsing these options and adjusting the type of plain chars accordingly. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
-rw-r--r--validation/char-signed.c9
-rw-r--r--validation/char-unsigned.c11
2 files changed, 20 insertions, 0 deletions
diff --git a/validation/char-signed.c b/validation/char-signed.c
new file mode 100644
index 00000000..7f657dac
--- /dev/null
+++ b/validation/char-signed.c
@@ -0,0 +1,9 @@
+void foo(void)
+{
+ _Static_assert((char) -1 == -1, "plain char is not signed");
+}
+
+/*
+ * check-name: fsigned-char
+ * check-command: sparse -fsigned-char -Wno-decl $file
+ */
diff --git a/validation/char-unsigned.c b/validation/char-unsigned.c
new file mode 100644
index 00000000..19cadbda
--- /dev/null
+++ b/validation/char-unsigned.c
@@ -0,0 +1,11 @@
+#define MASK ((1 << __CHAR_BIT__) - 1)
+
+void foo(void)
+{
+ _Static_assert((char) -1 == (-1 & MASK), "plain char is not unsigned");
+}
+
+/*
+ * check-name: fsigned-char
+ * check-command: sparse -funsigned-char -Wno-decl $file
+ */