diff options
| -rw-r--r-- | clang/lib/Sema/SemaExprCXX.cpp | 4 | ||||
| -rw-r--r-- | clang/test/CXX/class.access/p4.cpp | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp index e193cafbc2c..04c15e3f001 100644 --- a/clang/lib/Sema/SemaExprCXX.cpp +++ b/clang/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/clang/test/CXX/class.access/p4.cpp b/clang/test/CXX/class.access/p4.cpp index 115a22ad441..92b41b030d1 100644 --- a/clang/test/CXX/class.access/p4.cpp +++ b/clang/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; } +} |

