Recursively lifetime-extend into array temporaries. These can get implicitly
created through binding a reference-to-array to an initializer list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183594 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 60c67cd..7d73e08 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -3149,8 +3149,7 @@
const InitializedEntity &Entity,
const InitializationKind &Kind,
InitListExpr *InitList,
- InitializationSequence &Sequence)
-{
+ InitializationSequence &Sequence) {
// First, catch C++03 where this isn't possible.
if (!S.getLangOpts().CPlusPlus11) {
Sequence.SetFailed(InitializationSequence::FK_ReferenceBindingToInitList);
@@ -5216,7 +5215,7 @@
Init->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments));
if (InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) {
- if (ILE->initializesStdInitializerList()) {
+ if (ILE->initializesStdInitializerList() || ILE->getType()->isArrayType()) {
// FIXME: If this is an InitListExpr which creates a std::initializer_list
// object, we also need to lifetime-extend the underlying array
// itself. Fix the representation to explicitly materialize an
@@ -5226,7 +5225,7 @@
return;
}
- CXXRecordDecl *RD = Init->getType()->getAsCXXRecordDecl();
+ CXXRecordDecl *RD = ILE->getType()->getAsCXXRecordDecl();
if (RD) {
assert(RD->isAggregate() && "aggregate init on non-aggregate");