This patch attempts to fix a crash during instantiation of a direct destructor
call; as in foo::~foo().
Please review.
- Thanks, Fariborz
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===================================================================
--- lib/Sema/SemaTemplateInstantiateDecl.cpp (revision 227581)
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp (working copy)
@@ -4506,8 +4506,14 @@
NamedDecl *Result = nullptr;
if (D->getDeclName()) {
- DeclContext::lookup_result Found = ParentDC->lookup(D->getDeclName());
- Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
+ if (isa<CXXDestructorDecl>(D)) {
+ if (CXXRecordDecl *Spec = dyn_cast<CXXRecordDecl>(ParentDC))
+ if (!Spec->isDependentContext())
+ Result = LookupDestructor(Spec);
+ } else {
+ DeclContext::lookup_result Found =
ParentDC->lookup(D->getDeclName());
+ Result = findInstantiationOf(Context, D, Found.begin(), Found.end());
+ }
} else {
// Since we don't have a name for the entity we're looking for,
// our only option is to walk through all of the declarations to
Index: lib/Sema/TreeTransform.h
===================================================================
--- lib/Sema/TreeTransform.h (revision 227581)
+++ lib/Sema/TreeTransform.h (working copy)
@@ -7658,12 +7658,15 @@
// base (and therefore couldn't do the check) and a
// nested-name-qualifier (and therefore could do the lookup).
NamedDecl *FirstQualifierInScope = nullptr;
-
+ DeclarationNameInfo NameInfo = !isa<CXXDestructorDecl>(FoundDecl)
+ ? E->getMemberNameInfo()
+ :
DeclarationNameInfo(FoundDecl->getDeclName(),
+
FoundDecl->getLocation());
return getDerived().RebuildMemberExpr(Base.get(), FakeOperatorLoc,
E->isArrow(),
QualifierLoc,
TemplateKWLoc,
- E->getMemberNameInfo(),
+ NameInfo,
Member,
FoundDecl,
(E->hasExplicitTemplateArgs()
Index: test/SemaCXX/instantiate-explicit-destructor-call.cpp
===================================================================
--- test/SemaCXX/instantiate-explicit-destructor-call.cpp (revision 0)
+++ test/SemaCXX/instantiate-explicit-destructor-call.cpp (working copy)
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+// pr22394
+typedef __SIZE_TYPE__ size_t;
+template<class T> class foo
+{
+public:
+ inline foo() { }
+ inline ~ foo() { }
+
+ void *operator new(size_t n, foo*);
+ inline foo &operator = (const foo &rhs)
+ {
+ foo::~foo();
+ new (this) foo (rhs);
+ return *this;
+ }
+};
+
+int main(int argc, char * argv[])
+{
+ foo<int> a;
+ foo<int> b;
+ b = a;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits