diff options
author | John McCall <rjmccall@apple.com> | 2011-07-13 20:12:57 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2011-07-13 20:12:57 +0000 |
commit | 84ff0fccb180098b70504c03c3072a19e6d573af (patch) | |
tree | 3b6a63473c46a6cd02385ebbb4cec01674abb66d /lib | |
parent | 968860904a65619899c9f38673c8236a81240d93 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Sema/SemaExprCXX.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp index 7ee9c1bec2..e804fcd60c 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/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(); |