if (RD->hasIrrelevantDestructor())
return Owned(E);
- CXXDestructorDecl *Destructor
- = const_cast<CXXDestructorDecl*>(LookupDestructor(RD));
+ CXXDestructorDecl *Destructor = LookupDestructor(RD);
if (!Destructor)
return Owned(E);
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);
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} };
+}