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));
       }
     }
 


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));
       }
     }
 
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to