field-init of bitfields gives false 'duplicate initialization' error
type Foo struct {
u32 a : 1;
u32 b : 3;
}
Foo f1 = { 1, 2 } // ok
Foo f2 = { .a=1, .b=2 } // gives error: duplicate initialization of field 'b'
Needs to be fixed in StructFieldInitChecker
2 is an invalid initializer for bit-fieldb of length 1. Both initializers should give an error :)
The bit-width used to be 3, but I changed it to 1 without changing the init-value. Example should be good now.. The issue still remains.
We use an InitChecker to check for multiple initializers, but we should not use the offset alone.
We should use a range of bit offsets, which is supported by InitCheckers for case ranges. If StructTypeDecl.findAny would return the bit offset and bit width, we could use the add2 and find2 methods to check for multiple initialization of the same bits.
This limits structure sizes to 512 MB which is not a real concern.
fixed