diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-05-29 00:29:46 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-12-29 22:42:45 +0100 |
| commit | d1ad9561e9cd43373f692394567f627230a511d1 (patch) | |
| tree | a8017d22f5c1a75edee3f03f556a26fb1e76047c /validation | |
| parent | 95ae484069ebcf6d2d1f754451f898b0f23d3211 (diff) | |
| download | sparse-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.c | 9 | ||||
| -rw-r--r-- | validation/char-unsigned.c | 11 |
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 + */ |
