aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Sema/SemaInit.cpp')
-rw-r--r--clang/lib/Sema/SemaInit.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index b5f31bf..38f6a59 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8200,9 +8200,21 @@ ExprResult InitializationSequence::Perform(Sema &S,
if (S.CheckExceptionSpecCompatibility(CurInit.get(), DestType))
return ExprError();
+ QualType MTETy = Step->Type;
+
+ // When this is an incomplete array type (such as when this is
+ // initializing an array of unknown bounds from an init list), use THAT
+ // type instead so that we propogate the array bounds.
+ if (MTETy->isIncompleteArrayType() &&
+ !CurInit.get()->getType()->isIncompleteArrayType() &&
+ S.Context.hasSameType(
+ MTETy->getPointeeOrArrayElementType(),
+ CurInit.get()->getType()->getPointeeOrArrayElementType()))
+ MTETy = CurInit.get()->getType();
+
// Materialize the temporary into memory.
MaterializeTemporaryExpr *MTE = S.CreateMaterializeTemporaryExpr(
- Step->Type, CurInit.get(), Entity.getType()->isLValueReferenceType());
+ MTETy, CurInit.get(), Entity.getType()->isLValueReferenceType());
CurInit = MTE;
// If we're extending this temporary to automatic storage duration -- we