[clang] 2b943c4 - [Sema] Fixes a crash with a templated destructor
Mark de Wever via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 7 12:22:46 PST 2019
Author: Mark de Wever
Date: 2019-11-07T21:22:27+01:00
New Revision: 2b943c46873a6411c5a79dcd708d8c72ce5b3675
URL: https://github.com/llvm/llvm-project/commit/2b943c46873a6411c5a79dcd708d8c72ce5b3675
DIFF: https://github.com/llvm/llvm-project/commit/2b943c46873a6411c5a79dcd708d8c72ce5b3675.diff
LOG: [Sema] Fixes a crash with a templated destructor
The issue was introduced by D33189 which fixed PR33189.
Fixes PR38671: "destructor cannot be declared as a template" leads to segfault in Sema::LookupSpecialMember
Differential Revision: https://reviews.llvm.org/D69225
Added:
Modified:
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaTemplate/destructor-template.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 44c9d276c3e7..df817e6bcef1 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -3112,11 +3112,10 @@ Sema::SpecialMemberOverloadResult Sema::LookupSpecialMember(CXXRecordDecl *RD,
});
}
CXXDestructorDecl *DD = RD->getDestructor();
- assert(DD && "record without a destructor");
Result->setMethod(DD);
- Result->setKind(DD->isDeleted() ?
- SpecialMemberOverloadResult::NoMemberOrDeleted :
- SpecialMemberOverloadResult::Success);
+ Result->setKind(DD && !DD->isDeleted()
+ ? SpecialMemberOverloadResult::Success
+ : SpecialMemberOverloadResult::NoMemberOrDeleted);
return *Result;
}
diff --git a/clang/test/SemaTemplate/destructor-template.cpp b/clang/test/SemaTemplate/destructor-template.cpp
index 6570b6456406..0d28ec816c6e 100644
--- a/clang/test/SemaTemplate/destructor-template.cpp
+++ b/clang/test/SemaTemplate/destructor-template.cpp
@@ -92,3 +92,13 @@ class PR33189
template <class T>
~PR33189() { } // expected-error{{destructor cannot be declared as a template}}
};
+
+namespace PR38671 {
+struct S {
+ template <class>
+ ~S(); // expected-error{{destructor cannot be declared as a template}}
+};
+struct T : S { // expected-note{{destructor of 'T' is implicitly deleted because base class 'PR38671::S' has no destructor}}
+ ~T() = default; // expected-warning{{explicitly defaulted destructor is implicitly deleted}}
+};
+} // namespace PR38671
More information about the cfe-commits
mailing list