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

C++ attribute fixes #278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

C++ attribute fixes #278

wants to merge 4 commits into from

Conversation

Tsche
Copy link

@Tsche Tsche commented Jul 31, 2024

Currently tree-sitter-cpp uses attribute_declaration from the C parser. Since the grammar for attributes is different between C and C++, this is not sufficient.

Namely C++ allows using using in attributes, ie:

[[using gnu: always_inline, visibility("default")]]
inline int g();

//instead of
[[gnu::always_inline]] [[gnu::visibility("default")]]
inline int g();

Consequently tree-sitter-cpp currently errors with the above code. This patch fixes that.



Additionally this patch also implements attributed using-directives such as:

[[deprecated]] using namespace foo;

Currently, using-directives are parsed as using_declaration, consequently it now also accepts invalid using-declarations such as [[deprecated]] using typename foo; and invalid using-enum-declarations such as [[deprecated]] using enum foo;.

Please advise if pulling using-directives into their own using_directive node type is okay - that'd be more correct and alleviate this issue.

@Tsche
Copy link
Author

Tsche commented Nov 26, 2024

@amaanq please review the changes of this PR and advise on the using-directive issue

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.

1 participant