зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
abf9d908cc
Коммит
2835745a45
|
@ -641,8 +641,7 @@ ExprResult Sema::CheckCXXThrowOperand(SourceLocation ThrowLoc, Expr *E,
|
|||
if (RD->hasIrrelevantDestructor())
|
||||
return Owned(E);
|
||||
|
||||
CXXDestructorDecl *Destructor
|
||||
= const_cast<CXXDestructorDecl*>(LookupDestructor(RD));
|
||||
CXXDestructorDecl *Destructor = LookupDestructor(RD);
|
||||
if (!Destructor)
|
||||
return Owned(E);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -232,3 +232,21 @@ void fn11() {
|
|||
destroyme2 dm2;
|
||||
// CHECK: call void @_ZN10destroyme2D1Ev
|
||||
}
|
||||
|
||||
namespace PR12178 {
|
||||
struct string {
|
||||
string(int);
|
||||
~string();
|
||||
};
|
||||
|
||||
struct pair {
|
||||
string a;
|
||||
int b;
|
||||
};
|
||||
|
||||
struct map {
|
||||
map(std::initializer_list<pair>);
|
||||
};
|
||||
|
||||
map m{ {1, 2}, {3, 4} };
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче