In linearize_initializer(), 'ad->bit_size' & 'ad->bit_offset' were never set, making the correct initialization impossible (a bit_size of zero being especially bad, resulting in a mask of -1 instead of 0). This is now fixed since 'bit_size' & 'bit_offset' are taken directly from 'result_type'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@xxxxxxxxx> --- validation/linear/bitfield-init-mask.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 validation/linear/bitfield-init-mask.c diff --git a/validation/linear/bitfield-init-mask.c b/validation/linear/bitfield-init-mask.c new file mode 100644 index 000000000..94afa400c --- /dev/null +++ b/validation/linear/bitfield-init-mask.c @@ -0,0 +1,27 @@ +struct bfu { + unsigned int a:11; + unsigned int f:9; + unsigned int z:3; +}; + +struct bfu bfu_init_00_11(int a) +{ + struct bfu bfu = { .a = a, }; + return bfu; +} + +struct bfu bfu_init_20_23(int a) +{ + struct bfu bfu = { .z = a, }; + return bfu; +} + +/* + * check-name: bitfield initializer mask + * check-command: test-linearize -fdump-linearize=only -Wno-decl $file + * check-output-ignore + * + * check-output-contains: and\\..*fffff800\$ + * check-output-contains: shl\\..* \\$20 + * check-output-contains: and\\..*ff8fffff\$ + */ -- 2.12.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html