diff options
| author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-03-05 19:35:43 +0000 |
|---|---|---|
| committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-03-05 19:35:43 +0000 |
| commit | 2835745a451002798fed9800aeb19277f6a8fcb3 (patch) | |
| tree | 4df2d4e14933a851d5996829205bcb512199a73b /lib/Sema/SemaInit.cpp | |
| parent | abf9d908cce6ffe2ee7b739d98fc7344a4f9fe3b (diff) | |
| download | clang-2835745a451002798fed9800aeb19277f6a8fcb3.tar.gz clang-2835745a451002798fed9800aeb19277f6a8fcb3.tar.bz2 clang-2835745a451002798fed9800aeb19277f6a8fcb3.tar.xz | |
If the element type of an initializer list has a destructor, make sure we check it. Fixes PR12178.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152048 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
| -rw-r--r-- | lib/Sema/SemaInit.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index ba4453c08c..5d2536ae1b 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -5309,6 +5309,19 @@ InitializationSequence::Perform(Sema &S, bool Success = S.isStdInitializerList(Dest, &E); (void)Success; assert(Success && "Destination type changed?"); + + // If the element type has a destructor, check it. + if (CXXRecordDecl *RD = E->getAsCXXRecordDecl()) { + if (!RD->hasIrrelevantDestructor()) { + if (CXXDestructorDecl *Destructor = S.LookupDestructor(RD)) { + S.MarkFunctionReferenced(Kind.getLocation(), Destructor); + S.CheckDestructorAccess(Kind.getLocation(), Destructor, + S.PDiag(diag::err_access_dtor_temp) << E); + S.DiagnoseUseOfDecl(Destructor, Kind.getLocation()); + } + } + } + InitListExpr *ILE = cast<InitListExpr>(CurInit.take()); unsigned NumInits = ILE->getNumInits(); SmallVector<Expr*, 16> Converted(NumInits); |
