summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExprCXX.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-07-13 20:12:57 +0000
committerJohn McCall <rjmccall@apple.com>2011-07-13 20:12:57 +0000
commit928a25714e6d980e2eea215c24686d483015a8ac (patch)
tree8b66ce6ad95c60cd376d6333c81ccf6bcfc5ddc5 /clang/lib/Sema/SemaExprCXX.cpp
parent2371a3f14a9148ed341d27f3e256444c013c6c33 (diff)
downloadbcm5719-llvm-928a25714e6d980e2eea215c24686d483015a8ac.tar.gz
bcm5719-llvm-928a25714e6d980e2eea215c24686d483015a8ac.zip
Enforce access control for the destructor in a new[] expression and mark
it as used. Otherwise, we can fail to instantiate or validate the destructor, which can lead to crashes in IR gen like PR10351. llvm-svn: 135073
Diffstat (limited to 'clang/lib/Sema/SemaExprCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaExprCXX.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index 7ee9c1bec20..e804fcd60c7 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -1148,7 +1148,17 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal,
if (OperatorDelete)
MarkDeclarationReferenced(StartLoc, OperatorDelete);
- // FIXME: Also check that the destructor is accessible. (C++ 5.3.4p16)
+ // C++0x [expr.new]p17:
+ // If the new expression creates an array of objects of class type,
+ // access and ambiguity control are done for the destructor.
+ if (ArraySize && Constructor) {
+ if (CXXDestructorDecl *dtor = LookupDestructor(Constructor->getParent())) {
+ MarkDeclarationReferenced(StartLoc, dtor);
+ CheckDestructorAccess(StartLoc, dtor,
+ PDiag(diag::err_access_dtor)
+ << Context.getBaseElementType(AllocType));
+ }
+ }
PlacementArgs.release();
ConstructorArgs.release();
OpenPOWER on IntegriCloud