Don't remove MOD_SPECIFIER from 'bitwise' types
I'm sure there was some reason that was done, but it's trivially broken,
and means that the signedness bits are cleared.
In particular, it means that MOD_UNSIGNED is dropped off a 'bitwise'
type, and this trivial test-case shows the resulting breakage:
typedef unsigned int __attribute__((bitwise)) le32;
static long test(void)
{
return (le32) -1 <= (le32) 0;
}
and without the MOD_UNSIGNED on the bitwise type, this will end up as a
signed compare and return true (1):
[torvalds@ryzen sparse]$ ./test-linearize t.c
test:
.L0:
<entry-point>
ret.64 $1
when it clearly should return false (0).
At the same time this bit masking was very clearly intentional, and goes
all the way back to the original bitwise support in commit 032f492a
("[PATCH] __attribute__((bitwise))"), so there is probably some very
real reason for it despite the above obvious failure.
It's entirely possible that the real issue is that our signedness tests
are very lazy, and just look at
expr->ctype->ctype.modifiers & MOD_UNSIGNED
when it's very possible that they should simply drill deeper into the
type, and we should just use our is_signed_type() helper everywhere,
instead of just looking at the top-level 'modifiers' value.
But we do that 'look at modifiers directly' quite a _lot_.
Cc: Al Viro <viro@ZenIV.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2 files changed