diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-05 23:02:05 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-10-08 13:45:02 +0200 |
| commit | 56b9d0afc2dc70649d157865bf73c78f96621255 (patch) | |
| tree | db2208bb83b5507ea191e27572941d2104bf07ec /validation | |
| parent | b6a937a18d3bb80bce3b96dcdd7753032132852e (diff) | |
| download | sparse-dev-56b9d0afc2dc70649d157865bf73c78f96621255.tar.gz | |
fix usual conversion of integers
The current implementation of the usual conversion doesn't handle
correctly the case of 'long' + 'unsigned int' on a 32-bit arch.
The resulting type is 'unsigned int' instead of 'unsigned long'.
Fix this by following closely the C99's wording.
This now gives the expected result for C89 & C99 on 32 & 64-bit archs
(as tested with the GCC testsuite).
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation')
| -rw-r--r-- | validation/usual-conv-lp32.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/validation/usual-conv-lp32.c b/validation/usual-conv-lp32.c new file mode 100644 index 00000000..7f91288e --- /dev/null +++ b/validation/usual-conv-lp32.c @@ -0,0 +1,11 @@ +extern long l; +extern unsigned int u; + +#if __SIZEOF_LONG__ == __SIZEOF_INT__ +_Static_assert([typeof(l + u)] == [unsigned long], "ulong"); +#endif + +/* + * check-name: usual-conversions + * check-command: sparse -m32 $file + */ |
