diff options
| author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-09-16 23:19:19 +0200 |
|---|---|---|
| committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-09-16 23:19:19 +0200 |
| commit | 517177692e00fd36d89f1aac389348c9598bc426 (patch) | |
| tree | 1b0825895125bac64012c7f1ee28a37712c7184b /validation/optim | |
| parent | 24bdaac6682c36f5f7878321e8f9eb02c0993572 (diff) | |
| download | sparse-dev-517177692e00fd36d89f1aac389348c9598bc426.tar.gz | |
teach sparse about -funsigned-bitfields
Currently, Sparse treats 'plain' bitfields as unsigned.
However, this is this is inconsistent with how non-bitfield integers
are handled and with how GCC & clang handle bitfields.
So, teach sparse about '-funsigned-bitfields' and by default treat
these bitfields are signed, like done by GCC & clang and like done
for non-bitfield integers.
Also, avoid plain bitfields in IR related testcases.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Diffstat (limited to 'validation/optim')
| -rw-r--r-- | validation/optim/bitfield-size.c | 15 | ||||
| -rw-r--r-- | validation/optim/bitfield-store-loads.c | 4 |
2 files changed, 4 insertions, 15 deletions
diff --git a/validation/optim/bitfield-size.c b/validation/optim/bitfield-size.c index 0d2deeea..ea1ed57f 100644 --- a/validation/optim/bitfield-size.c +++ b/validation/optim/bitfield-size.c @@ -19,17 +19,6 @@ signed int get__bfs_b(struct bfs bf) { return bf.b; } signed int get_pbfs_a(struct bfs *bf) { return bf->a; } signed int get_pbfs_b(struct bfs *bf) { return bf->b; } - -struct bfi { - int a:4; - int :2; - int b:4; -}; -unsigned int get__bfi_a(struct bfi bf) { return bf.a; } -unsigned int get__bfi_b(struct bfi bf) { return bf.b; } -unsigned int get_pbfi_a(struct bfi *bf) { return bf->a; } -unsigned int get_pbfi_b(struct bfi *bf) { return bf->b; } - /* * check-name: bitfield size * check-command: test-linearize -Wno-decl $file @@ -37,8 +26,8 @@ unsigned int get_pbfi_b(struct bfi *bf) { return bf->b; } * * check-output-excludes: and\\..*\\$960 * check-output-excludes: zext\\. - * check-output-pattern(8): and\\..*\\$15 + * check-output-pattern(4): and\\..*\\$15 * check-output-pattern(4): sext\\. * check-output-pattern(4): trunc\\.4 - * check-output-pattern(6): lsr\\..*\\$6 + * check-output-pattern(4): lsr\\..*\\$6 */ diff --git a/validation/optim/bitfield-store-loads.c b/validation/optim/bitfield-store-loads.c index dc625131..f946715b 100644 --- a/validation/optim/bitfield-store-loads.c +++ b/validation/optim/bitfield-store-loads.c @@ -1,6 +1,6 @@ struct s { - char :2; - char f:3; + unsigned char :2; + unsigned char f:3; }; int foo(struct s s, int a) |
