mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 19:56:38 +00:00
[clang] Do not crash on undefined template partial specialization
Before checking that template partial specialization is "reachable", ensure it exists. Fixes https://github.com/llvm/llvm-project/issues/61356 Reviewed By: shafik, erichkeane Differential Revision: https://reviews.llvm.org/D148330
This commit is contained in:
parent
19732a3eaa
commit
7c97dc20ab
@ -325,6 +325,8 @@ Bug Fixes in This Version
|
||||
member pointer as an invalid expression.
|
||||
- Fix crash when member function contains invalid default argument.
|
||||
(`#62122 <https://github.com/llvm/llvm-project/issues/62122>`_)
|
||||
- Fix crash when handling undefined template partial specialization
|
||||
(`#61356 <https://github.com/llvm/llvm-project/issues/61356>`_)
|
||||
|
||||
Bug Fixes to Compiler Builtins
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
@ -131,7 +131,8 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS,
|
||||
// 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);
|
||||
|
15
clang/test/SemaCXX/undefined-partial-specialization.cpp
Normal file
15
clang/test/SemaCXX/undefined-partial-specialization.cpp
Normal file
@ -0,0 +1,15 @@
|
||||
// RUN: %clang_cc1 -std=c++17 -verify %s
|
||||
// RUN: %clang_cc1 -std=c++20 -verify %s
|
||||
|
||||
namespace GH61356 {
|
||||
|
||||
template <typename T, bool b>
|
||||
class boo {void foo();};
|
||||
|
||||
template <typename T>
|
||||
class boo<T, true>;
|
||||
|
||||
template<typename T>
|
||||
void boo<T, true>::foo(){} // expected-error{{out-of-line definition of 'foo' from class 'boo<type-parameter-0-0, true>' without definition}}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user