Check access for the implicit calls to destructors that occur when we
have a temporary object in C++.
Also fix a tag mismatch that Doug noticed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100593 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index 501c877..f6adb15 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -2450,8 +2450,12 @@
RD->getDestructor(Context));
ExprTemporaries.push_back(Temp);
if (CXXDestructorDecl *Destructor =
- const_cast<CXXDestructorDecl*>(RD->getDestructor(Context)))
+ const_cast<CXXDestructorDecl*>(RD->getDestructor(Context))) {
MarkDeclarationReferenced(E->getExprLoc(), Destructor);
+ CheckDestructorAccess(E->getExprLoc(), Destructor,
+ PDiag(diag::err_access_dtor_temp)
+ << E->getType());
+ }
// FIXME: Add the temporary to the temporaries vector.
return Owned(CXXBindTemporaryExpr::Create(Context, Temp, E));
}