[HIP][OpenMP] Fix assertion in deferred diag

Fix assertion in UsedDeclVisitor where clang is trying to look up a destructor
for a forward declared class.

Fixes: https://bugs.llvm.org/show_bug.cgi?id=52250

Reviewed by: Artem Belevich, John McCall

Differential Revision: https://reviews.llvm.org/D112235
This commit is contained in:
Yaxun (Sam) Liu 2021-10-21 12:59:49 -04:00
parent 5c46986cc8
commit a5435844f0
2 changed files with 13 additions and 3 deletions

View File

@ -72,7 +72,8 @@ public:
QualType Destroyed = S.Context.getBaseElementType(DestroyedOrNull);
if (const RecordType *DestroyedRec = Destroyed->getAs<RecordType>()) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
if (Record->getDefinition())
asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
}
}

View File

@ -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,14 @@ public:
}
}
};
// Test that deleting an incomplete class type doesn't cause an 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