diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -303,6 +303,8 @@ - Fix a failed assertion due to an invalid source location when trying to form a coverage report for an unresolved constructor expression. (`#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 @@ -131,7 +131,8 @@ // entering the context, and that can't happen in a SFINAE context. assert(!isSFINAEContext() && "partial specialization scope " "specifier in SFINAE context?"); - if (!hasReachableDefinition(PartialSpec)) + if (PartialSpec->hasDefinition() && + !hasReachableDefinition(PartialSpec)) diagnoseMissingImport(SS.getLastQualifierNameLoc(), PartialSpec, MissingImportKind::PartialSpecialization, true); 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,15 @@ +// RUN: %clang_cc1 -std=c++17 -verify %s +// RUN: %clang_cc1 -std=c++20 -verify %s + +namespace GH61356 { + +template +class boo {void foo();}; + +template +class boo; + +template +void boo::foo(){} // expected-error{{out-of-line definition of 'foo' from class 'boo' without definition}} + +}