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

Fails to parse some GNU attributes #8

Closed
cdisselkoen opened this issue Apr 7, 2021 · 2 comments · Fixed by #30
Closed

Fails to parse some GNU attributes #8

cdisselkoen opened this issue Apr 7, 2021 · 2 comments · Fixed by #30

Comments

@cdisselkoen
Copy link
Contributor

FrontC fails to parse __attribute__((__aligned__(__alignof__(long long)))). This appears in stddef.h on my system, or technically in __stddef_max_align_t.h which is #included in stddef.h.

I believe the root cause of the problem is that here, the rule which matches __alignof__(*) expects an identifier, a constant, or another expression involving parens, but instead it gets long long.

@ivg
Copy link
Member

ivg commented Apr 12, 2021

The long long built-in type was introduced only in C99 and FrontC supports only C89. So it is the expected behavior, see also #9.

If you want to introduce the C99 built-in types, i.e., long long, _Bool, _Complex, and _Imaginary, you need to add them to the built-in lexicon of identifiers here, e.g.,

		("long long", id LLONG);

and add the corresponding tokens (LLONG, BOOL, COMPLEX, and IMAGINARY), here. We probably also need to update the scan_ident primitive so that it accepts strings like long .. <many spaces> ..long1, i.e., we need to strip repetitive whitespace.

Finally, we will need to deal with the ambiguity in the modifier parser that our change will introduce. As previously long long was not parsed as a builtin type, but rather than a modifier to long so that long long x; was accepted but sizeof(long long) or alignof(long long) were not.


1) Githubs markdown eats consecutive spaces even inside backticked strings, but you got the idea.

@ivg
Copy link
Member

ivg commented May 13, 2021

In fact, the main culprit is that gnu attributes are not allowed in a structure field definition.

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 a pull request may close this issue.

2 participants