Elab bitfields: check size of type <=32bit rather than checking rank #387
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello,
I had an issue with bitfields when using standard headers from newlib on ARM. The
uint32_t
typedef was defined asunsigned long
, so the bitfield elaborator was complaining even though it was still only 32 bits. To fix this, I've changed the test in Elab.ml to check the size of the integer rather than the rank. I haven't gone through all the details of Bitfields.ml, but it looks like the logic depends on the size being <=32 rather than the rank, so I believe it is still correct.I've added a test case but this is a bit tricky to run automatically, since it relies on a specific 32-bit configuration. I also manually inspected the generated assembly for ARM-v7m and it was correct.
Issue 315 sounds superficially similar, but this is a much simpler change as it still only supports 32-bit values. This change just allows you to refer to them with another name.
Thanks,
Amos
When desugaring a bitfield, allow any integral type that is 32 bits
or smaller. Previously this was checking the rank of the type rather
than the size.
This rank check caused issues with standard headers that
declare
uint32_t
to be anunsigned long
rather than anunsigned int
. Here, any bitfields declared asuint32_t
werefailing to compile even though they are still actually 32 bits.