[clang] a543584 - [HIP][OpenMP] Fix assertion in deferred diag
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 25 08:08:01 PDT 2021
Author: Yaxun (Sam) Liu
Date: 2021-10-25T11:07:40-04:00
New Revision: a5435844f0e67c70963a1a743fef41b1a8eac4d3
URL: https://github.com/llvm/llvm-project/commit/a5435844f0e67c70963a1a743fef41b1a8eac4d3
DIFF: https://github.com/llvm/llvm-project/commit/a5435844f0e67c70963a1a743fef41b1a8eac4d3.diff
LOG: [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
Added:
Modified:
clang/lib/Sema/UsedDeclVisitor.h
clang/test/OpenMP/deferred-diags.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/UsedDeclVisitor.h b/clang/lib/Sema/UsedDeclVisitor.h
index c33d30478e2a..24b7342b3fb4 100644
--- a/clang/lib/Sema/UsedDeclVisitor.h
+++ b/clang/lib/Sema/UsedDeclVisitor.h
@@ -72,7 +72,8 @@ class UsedDeclVisitor : public EvaluatedExprVisitor<Derived> {
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));
}
}
diff --git a/clang/test/OpenMP/deferred-diags.cpp b/clang/test/OpenMP/deferred-diags.cpp
index 037498b7fedb..0c38e68ae81a 100644
--- a/clang/test/OpenMP/deferred-diags.cpp
+++ b/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,14 @@ class A : public B {
}
}
};
+
+// 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
More information about the cfe-commits
mailing list