diff --git a/src/CppParser/Parser.cpp b/src/CppParser/Parser.cpp index a1ea4246..30e12eba 100644 --- a/src/CppParser/Parser.cpp +++ b/src/CppParser/Parser.cpp @@ -887,6 +887,23 @@ void Parser::WalkRecord(const clang::RecordDecl* Record, Class* RC) continue; WalkDeclaration(D); break; + case Decl::Friend: + { + FriendDecl* FD = cast(D); + auto decl = FD->getFriendDecl(); + + // Skip every friend declaration that isn't a function declaration + if (decl && !isa(decl)) + continue; + WalkDeclaration(D); + break; + } + case Decl::FriendTemplate: + { + // In this case always skip the declaration since, unlike Decl::Friend handled above, + // it never is a declaration of a friend function or method + break; + } default: { WalkDeclaration(D); diff --git a/tests/CSharp/CSharpTemplates.h b/tests/CSharp/CSharpTemplates.h index bd0e990c..a2e7abad 100644 --- a/tests/CSharp/CSharpTemplates.h +++ b/tests/CSharp/CSharpTemplates.h @@ -474,3 +474,23 @@ template class DLL_API TemplateWithIndexer; template class DLL_API TemplateWithIndexer; class TestForwardedClassInAnotherUnit; + +// Forward declaration of class as friend +template class ForwardTemplateFriendClassContainer; +template class ForwardTemplateFriendClass; + +template +class ForwardTemplateFriendClassContainer +{ + template friend class ForwardTemplateFriendClass; +}; + +template +class ForwardTemplateFriendClass +{ +protected: + ForwardTemplateFriendClass() { } +}; + +class ForwardTemplateFriendClassUser : public ForwardTemplateFriendClass +{ }; \ No newline at end of file