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

Adding support for alignas type qualifier #207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

touzeauv
Copy link

This commit adds support for alignas type qualifier, as asked in issue #206.

I do not fully understand the current state of the tree-sitter-c grammar, I might have done some mistake.
In particular, please double check the following point:

  • I added "alignas" as a type_qualifier whereas cppreference considers it is a "type specifier". I am not sure I understand the distinction between "specifier" and "qualifier" but type_qualifier seemed more appropriate to me.
  • I chose to make alignas_qualifier nodes visible in the tree. I don't have an intuition about when to hide, show or rename nodes in the tree, so I might be wrong here.

The commit includes a small modification of the test corpus to avoid future regressions.

PS: Thanks for your work maintaining tree-sitter

@amaanq
Copy link
Member

amaanq commented May 14, 2024

Ah interesting - I added support for this in CPP, but I think your change makes sense to have in C and have C++ inherit it. There's one lingering question though, should the second choice be type_descriptor, or would _type_specifier suffice? If there can be qualifiers in the type inside the alignas type qualifier then this is good, but just want to double check

@touzeauv
Copy link
Author

I think type_descriptor is required for the second choice. cppreference the argument of alignas is a type-id, which might include qualifiers I believe.
Testing gcc and clang, both accept things such as alignas(volatile const int) char c;

Regarding C++, it seems the language only allows alignas, but not _Alignas.
clang++ is permissive and will parse it without complaining, but g++ complains that _Alignas is not declared.

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.

None yet

2 participants