]> granicus.if.org Git - clang/commitdiff
PR8325: don't do destructor checking when a pointer is thrown.
authorEli Friedman <eli.friedman@gmail.com>
Tue, 12 Oct 2010 20:32:36 +0000 (20:32 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Tue, 12 Oct 2010 20:32:36 +0000 (20:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116336 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExprCXX.cpp
test/CXX/class.access/p4.cpp

index e193cafbc2c49296447e2ca01f774e269974c844..04c15e3f0019299c738c8f04780e72b814bae0be 100644 (file)
@@ -509,6 +509,10 @@ bool Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *&E) {
   // exception handling will make use of the vtable.
   MarkVTableUsed(ThrowLoc, RD);
 
+  // If a pointer is thrown, the referenced object will not be destroyed.
+  if (isPointer)
+    return false;
+
   // If the class has a non-trivial destructor, we must be able to call it.
   if (RD->hasTrivialDestructor())
     return false;
index 115a22ad44125e057d70a80535a150a6c2be799c..92b41b030d1bc112a39e822427008c4c6693df05 100644 (file)
@@ -450,3 +450,11 @@ namespace test18 {
     A<int> member;
   };
 }
+
+// PR8325
+namespace test19 {
+  class A { ~A(); };
+  // The destructor is not implicitly referenced here.  Contrast to test16, 
+  // testing PR7281, earlier in this file.
+  void b(A* x) { throw x; }
+}