aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Sema/SemaExprCXX.cpp4
-rw-r--r--test/CXX/class.access/p4.cpp8
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index e193cafbc2..04c15e3f00 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -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;
diff --git a/test/CXX/class.access/p4.cpp b/test/CXX/class.access/p4.cpp
index 115a22ad44..92b41b030d 100644
--- a/test/CXX/class.access/p4.cpp
+++ b/test/CXX/class.access/p4.cpp
@@ -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; }
+}