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

Enum sizes #308

Merged
merged 12 commits into from
Jun 24, 2022
Merged

Enum sizes #308

merged 12 commits into from
Jun 24, 2022

Conversation

ehaas
Copy link
Collaborator

@ehaas ehaas commented Jun 20, 2022

Calculate enum sizes, accounting for packed attributes and overflow

src/Parser.zig Outdated
@@ -2076,6 +2087,40 @@ const Enumerator = struct {
e.res = res;
// TODO adjust res type to try to fit with the previous type
}

fn tagSpec(e: *const Enumerator, p: *Parser, is_packed: bool, tok: TokenIndex) !Type.Specifier {
Copy link
Owner

Choose a reason for hiding this comment

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

The spec in enumSpec and recordSpec comes from the official grammar, maybe it would be better to call this getTagType or even just tagType?

src/Parser.zig Show resolved Hide resolved
@Vexu Vexu mentioned this pull request Jun 23, 2022
@ehaas ehaas marked this pull request as draft June 23, 2022 21:14
@Vexu Vexu merged commit 1260b24 into Vexu:master Jun 24, 2022
@Vexu
Copy link
Owner

Vexu commented Jun 24, 2022

Thanks for this! This might still need some tweaking to match clang, on my machine clang says the enum in enum overflow.c has type long long instead of unsigned long and clang generally seems to prefer long long over long even if they're the same size.

Also sorry for hijacking your branch at the end. I assumed you were done with this thought to add the two missing parts so that this PR would get enums to a (mostly) complete state but they turned out to be more complex than I assumed.

@ehaas
Copy link
Collaborator Author

ehaas commented Jun 24, 2022

Sounds good! I can take a look at the overflowed enums

@ehaas ehaas deleted the enum-sizes branch June 24, 2022 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants