Skip to content
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

Support align and packed repr layout on structs #1188

Merged
merged 1 commit into from
Apr 29, 2022

Conversation

dafaust
Copy link
Collaborator

@dafaust dafaust commented Apr 27, 2022

This is a start at handling the various layout options supported by Rust, beginning with #[repr(align(N))] and #[repr(packed(N))], on structs and tuple structs.

There are several other layout options which remain to be supported such as #[repr(C)], #[repr(transparent)], combinations e.g. #[repr(C, packed(2))], as well as layouts on union and enum types.

Fixes: #915

@dafaust dafaust marked this pull request as ready for review April 28, 2022 16:21
@philberty philberty added this to the Imports and visibility milestone Apr 29, 2022
= meta_items->get_items ().at (0)->as_string ();

// TODO: it would probably be better to make the MetaItems more aware
// of constructs with nesting like #[repr(packed(2))] rather than
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i think your right here the AST Meta stuff is not very helpful to work with at the moment.

// parsing the #[repr] attribute.
unsigned char align = 0;
unsigned char pack = 0;
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be worth having some kind of error node state here. For example, during the type-checking of this structure, you could represent an error state by a flag or something so that when you are compiling the type we know if it's ok or not so we can error or ignore the options. This will only really matter down the line when we get rid of the saw_errors guards between each compiler pass.

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work LGTM

@philberty
Copy link
Member

philberty commented Apr 29, 2022

Lets see if you can bors this. I changed your permissions last time to try and fix it again, permissions are confusing lol

@philberty philberty removed the request for review from CohenArthur April 29, 2022 14:23
@dafaust
Copy link
Collaborator Author

dafaust commented Apr 29, 2022

bors r+

@philberty
Copy link
Member

looks like its working!! @dafaust nice :D

@dafaust
Copy link
Collaborator Author

dafaust commented Apr 29, 2022

🎉 hooray :P

@bors
Copy link
Contributor

bors bot commented Apr 29, 2022

Build succeeded:

@bors bors bot merged commit f38bf60 into Rust-GCC:master Apr 29, 2022
@dafaust dafaust deleted the adt-repr-merge branch May 4, 2022 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

support repr layout options of aligned and packed on structures
2 participants