[PATCH] D112235: [HIP][OpenMP] Fix assertion in deferred diag due to incomplete class definition

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 25 08:08:06 PDT 2021


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rGa5435844f0e6: [HIP][OpenMP] Fix assertion in deferred diag (authored by yaxunl).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D112235?vs=381307&id=382005#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D112235/new/

https://reviews.llvm.org/D112235

Files:
  clang/lib/Sema/UsedDeclVisitor.h
  clang/test/OpenMP/deferred-diags.cpp


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,14 @@
      }
   }
 };
+
+// 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
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<RecordType>()) {
         CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
-        asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
+        if (Record->getDefinition())
+          asImpl().visitUsedDecl(E->getBeginLoc(), S.LookupDestructor(Record));
       }
     }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112235.382005.patch
Type: text/x-patch
Size: 1493 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211025/fd788006/attachment.bin>


More information about the cfe-commits mailing list