tree-sitter-cpp
tree-sitter-cpp copied to clipboard
bug: parse error on `extern "C" using foobar = void (*)(void);`
Did you check existing issues?
- [x] I have read all the tree-sitter docs if it relates to using the parser
- [x] I have searched the existing issues of tree-sitter-cpp
Tree-Sitter CLI Version, if relevant (output of tree-sitter --version)
0.25.1
Describe the bug
tree-sitter-cpp does not understand an extremely obscure using declaration: extern "C" on function pointer type alias declarations, for strict correctness in not mixing linkage; though I think most compilers do not care because programmers are way too sloppy to get away with enforcing it.
extern "C" using NixPluginEntry = void (*)();
Compiles successfully with clang++ -std=c++23 -c test.cpp.
Steps To Reproduce/Bad Parse Tree
Apply this patch to your tree-sitter-cpp:
diff --git a/test/corpus/declarations.txt b/test/corpus/declarations.txt
index acaf288..d0dec09 100644
--- a/test/corpus/declarations.txt
+++ b/test/corpus/declarations.txt
@@ -106,6 +106,8 @@ using a = typename b<T>::c;
using foobar [[deprecated]] = int;
using foobar [[deprecated]] [[maybe_unused]] = int;
+extern "C" using foobar = void (*)(void);
+
--------------------------------------------------------------------------------
(translation_unit
Run tree-sitter test.
Obtain parse failure:
(linkage_specification
(string_literal
(string_content))
(declaration
(type_identifier)
(init_declarator
(identifier)
(call_expression
(call_expression
(primitive_type)
(argument_list
(ERROR)))
(argument_list
(ERROR
(primitive_type))))))))
Expected Behavior/Parse Tree
I don't know what the parse tree should look like, I just know the highlight broke and there should not be ERROR nodes in there.
Repro
extern "C" using foobar = void (*)(void);