Fix nested lifetime extension when a std::initializer_list member is
initialized during aggregate initialization of the surrounding structure.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@185117 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 9370287..f59571a 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -5348,13 +5348,15 @@
I != E; ++I) {
if (I->isUnnamedBitfield())
continue;
+ Expr *SubInit = ILE->getInit(Index);
if (I->getType()->isReferenceType())
- performReferenceExtension(ILE->getInit(Index), ExtendingD);
- else if (isa<InitListExpr>(ILE->getInit(Index)))
+ performReferenceExtension(SubInit, ExtendingD);
+ else if (isa<InitListExpr>(SubInit) ||
+ isa<CXXStdInitializerListExpr>(SubInit))
// This may be either aggregate-initialization of a member or
// initialization of a std::initializer_list object. Either way,
// we should recursively lifetime-extend that initializer.
- performLifetimeExtension(ILE->getInit(Index), ExtendingD);
+ performLifetimeExtension(SubInit, ExtendingD);
++Index;
}
}