diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -301,6 +301,8 @@ expressions/statements with invalid source locations in non-assert builds. Assert builds may still see assertions triggered from this. (`#62105 `_) +- Fix crash when handling undefined template partial specialization + (`#61356 `_) Bug Fixes to Compiler Builtins ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaCXXScopeSpec.cpp b/clang/lib/Sema/SemaCXXScopeSpec.cpp --- a/clang/lib/Sema/SemaCXXScopeSpec.cpp +++ b/clang/lib/Sema/SemaCXXScopeSpec.cpp @@ -125,7 +125,7 @@ PartialSpec = ClassTemplate->findPartialSpecialization(ContextType); } - if (PartialSpec) { + if (PartialSpec && PartialSpec->hasDefinition()) { // A declaration of the partial specialization must be visible. // We can always recover here, because this only happens when we're // entering the context, and that can't happen in a SFINAE context. diff --git a/clang/test/SemaCXX/undefined-partial-specialization.cpp b/clang/test/SemaCXX/undefined-partial-specialization.cpp new file mode 100644 --- /dev/null +++ b/clang/test/SemaCXX/undefined-partial-specialization.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s + +namespace GH61356 { + +template +class boo {void foo();}; + +template +class boo; + +template +void boo::foo(){} // expected-error{{nested name specifier 'boo::' for declaration does not refer into a class, class template or class template partial specialization}} + +}