PR8325: don't do destructor checking when a pointer is thrown.

llvm-svn: 116336
This commit is contained in:
Eli Friedman 2010-10-12 20:32:36 +00:00
parent 8ac477ffb5
commit 36ebbec121
2 changed files with 12 additions and 0 deletions

View 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;

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