diff options
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/incomplete-call.cpp | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index d54696bbef..5ac248d36b 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -6854,8 +6854,9 @@ canRecoverDotPseudoDestructorCallsOnPointerObjects(Sema &SemaRef, QualType DestructedType) { // If this is a record type, check if its destructor is callable. if (auto *RD = DestructedType->getAsCXXRecordDecl()) { - if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD)) - return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false); + if (RD->hasDefinition()) + if (CXXDestructorDecl *D = SemaRef.LookupDestructor(RD)) + return SemaRef.CanUseDecl(D, /*TreatUnavailableAsInvalid=*/false); return false; } diff --git a/test/SemaCXX/incomplete-call.cpp b/test/SemaCXX/incomplete-call.cpp index 6f5169ee8a..0fb1ef5f07 100644 --- a/test/SemaCXX/incomplete-call.cpp +++ b/test/SemaCXX/incomplete-call.cpp @@ -48,6 +48,10 @@ void test_incomplete_object_call(C& c) { c(); // expected-error{{incomplete type in call to object of type}} } +void test_incomplete_object_dtor(C *p) { + p.~C(); // expected-error{{member reference type 'C *' is a pointer; did you mean to use '->'?}} +} + namespace pr18542 { struct X { int count; |