diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -652,6 +652,8 @@ (`#63169 _`) - Fix crash when casting an object to an array type. (`#63758 _`) +- Fix crash on nested templated class with template function call. + (`#61159 _`) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -258,6 +258,11 @@ /*Final=*/false); } + if (const MemberSpecializationInfo *MSInfo = + Rec->getMemberSpecializationInfo()) + if (MSInfo->getTemplateSpecializationKind() == TSK_ExplicitSpecialization) + return Response::Done(); + bool IsFriend = Rec->getFriendObjectKind() || (Rec->getDescribedClassTemplate() && Rec->getDescribedClassTemplate()->getFriendObjectKind()); diff --git a/clang/test/SemaTemplate/gh61159.cpp b/clang/test/SemaTemplate/gh61159.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaTemplate/gh61159.cpp @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s +// expected-no-diagnostics + + +namespace GH61159 { +template +struct X { + struct impl; +}; + + +template <> +struct X::impl { + template + int f() { return ct; }; +}; + +void foo() { + X::impl{}.f<17>(); +} +}