diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-10 11:45:16 +0100 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-14 01:03:41 +0100 |
| commit | ebe086222f89521de5390bc204ed31976f4b97f4 (patch) | |
| tree | aac32f8f002e36a65bd943c6e087b7aa02512291 /validation | |
| parent | fd3528aa0409874386610ce63bb647fff8312fd9 (diff) | |
| download | sparse-dev-ebe086222f89521de5390bc204ed31976f4b97f4.tar.gz | |
arch: fix the signedness of plain chars
Some architectures, like ARM or PPC, use 'unsigned' for
plain chars while others, like the Intel's, use signed ones.
Sparse understands -funsigned-char but by default uses the
native signedness.
Fix this by setting the proper signedness of plain chars
for the archs that Sparse know about.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/char-signed-native.c | 9 | ||||
| -rw-r--r-- | validation/char-unsigned-native.c | 11 | ||||
| -rw-r--r-- | validation/char-unsigned.c | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/validation/char-signed-native.c b/validation/char-signed-native.c new file mode 100644 index 00000000..5185fce9 --- /dev/null +++ b/validation/char-signed-native.c @@ -0,0 +1,9 @@ +void foo(void) +{ + _Static_assert((char) -1 == -1, "plain char is not signed"); +} + +/* + * check-name: char-signed-native + * check-command: sparse --arch=i386 -Wno-decl $file + */ diff --git a/validation/char-unsigned-native.c b/validation/char-unsigned-native.c new file mode 100644 index 00000000..b8645842 --- /dev/null +++ b/validation/char-unsigned-native.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: char-unsigned-native + * check-command: sparse --arch=arm -Wno-decl $file + */ diff --git a/validation/char-unsigned.c b/validation/char-unsigned.c index 19cadbda..354aa40d 100644 --- a/validation/char-unsigned.c +++ b/validation/char-unsigned.c @@ -6,6 +6,6 @@ void foo(void) } /* - * check-name: fsigned-char + * check-name: funsigned-char * check-command: sparse -funsigned-char -Wno-decl $file */ |
