-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding offsetof checks as static assertions when refining a C type #144
Conversation
then false | ||
else let suffix' = String.sub s (l - sl) sl in | ||
suffix = suffix' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to Utils
offsets |> | ||
List.collect | ||
(fun offset -> | ||
if TypeSizes.is_alignment_field (fst offset) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exclude assertions on fields that are added for alignment padding; they are implicit in the C type
let ds = List.map (decl_size_with_alignment env) ds in | ||
let ge = B.global_env_of_env (fst env) in | ||
ds |> List.iter (fun d -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the global environment with revised type declarations after fields (may) have been added for alignment padding
#ifndef C_ASSERT | ||
#define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1] | ||
#endif | ||
typedef char CIRCLE[20]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revise the test case, since we now also check offsets, not just sizes
Cf. Issue #143