Index: clang/lib/Sema/UsedDeclVisitor.h =================================================================== --- clang/lib/Sema/UsedDeclVisitor.h +++ clang/lib/Sema/UsedDeclVisitor.h @@ -72,7 +72,8 @@ QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull); if (const RecordType *DestroyedRec = Destroyed->getAs()) { CXXRecordDecl *Record = cast(DestroyedRec->getDecl()); - asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record)); + if (Record->getDefinition()) + asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record)); } } Index: clang/test/OpenMP/deferred-diags.cpp =================================================================== --- clang/test/OpenMP/deferred-diags.cpp +++ clang/test/OpenMP/deferred-diags.cpp @@ -6,8 +6,6 @@ // RUN: -verify-ignore-unexpected=note \ // RUN: -fopenmp -o - %s -// expected-no-diagnostics - // Test no infinite recursion in DeferredDiagnosticEmitter. constexpr int foo(int *x) { return 0; @@ -37,3 +35,15 @@ } } }; + +// Test deleting object with incomplete class definition does not causing +// assertion. +namespace TestDeleteIncompleteClassDefinition { +struct a; +struct b { + b() { + delete c; + } // expected-warning {{deleting pointer to incomplete type 'TestDeleteIncompleteClassDefinition::a' may cause undefined behavior}} + a *c; +}; +} // namespace TestDeleteIncompleteClassDefinition