Add support for __attribute__(()) in enum/struct/union by douglas-raillard-arm · Pull Request #76 · inducer/pycparserext · GitHub
Skip to content

Add support for __attribute__(()) in enum/struct/union - #76

Open
douglas-raillard-arm wants to merge 2 commits into
inducer:mainfrom
douglas-raillard-arm:struct_attr
Open

douglas-raillard-arm wants to merge 2 commits into
inducer:mainfrom
douglas-raillard-arm:struct_attr

Conversation

@douglas-raillard-arm

@douglas-raillard-arm douglas-raillard-arm commented Sep 1, 2023

Copy link
Copy Markdown
Contributor

Add support for GNU __attribute__(()) in enum/struct/union definitions, both on the type itself and on enumerators.

Fixes #42

@inducer

inducer commented Sep 1, 2023

Copy link
Copy Markdown
Owner

@douglas-raillard-arm

Copy link
Copy Markdown
Contributor Author

@inducer I just realized that at least GCC accepts multiple __attribute__(()) on the same declaration. That PR works when they are next to each-other but obviously not if they are in multiple positions. I tried a production like that:

struct_or_union_specifier   : struct_or_union attributes_opt ID brace_open brace_close attributes_opt

But this only matches if there is an __attribute__(()) in each position, so that would lead to pretty bad combinatorial explosion of the number rules. Do you have any suggestion to fix that ?

@inducer

inducer commented Sep 4, 2023

Copy link
Copy Markdown
Owner

But this only matches if there is an __attribute__(()) in each position

Not sure I understand. Wouldn't each attributes_opt be optional individually?

@douglas-raillard-arm

Copy link
Copy Markdown
Contributor Author

Not sure I understand. Wouldn't each attributes_opt be optional individually?

Yes, I did not realize it actually worked because of another issue. I'm reworking the rules to allow __attribute__(()) in multiple position at once, I'll update the PR when it's ready.

Add support for GNU __attribute__(()) in enum/struct/union definitions,
both on the type itself and on enumerators.

Fixes inducer#42

Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
@douglas-raillard-arm

Copy link
Copy Markdown
Contributor Author

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.

struct in a struct with __attribute__((packed))

2 participants