From 98efb9f6df133f5508d260c4510c6c3bd70f34ad Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 12 Oct 2010 20:32:36 +0000 Subject: [PATCH] PR8325: don't do destructor checking when a pointer is thrown. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@116336 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaExprCXX.cpp | 4 ++++ test/CXX/class.access/p4.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) 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 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; } +} -- 2.40.0