Be more careful when checking initializer lists that involve reference
types; we don't want to give an expression reference type. Fixes PR6177.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95635 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index f536701..3e710cf 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -510,8 +510,8 @@
StructuredList->setSyntacticForm(IList);
CheckListElementTypes(Entity, IList, T, /*SubobjectIsDesignatorContext=*/true,
Index, StructuredList, StructuredIndex, TopLevelObject);
- IList->setType(T);
- StructuredList->setType(T);
+ IList->setType(T.getNonReferenceType());
+ StructuredList->setType(T.getNonReferenceType());
if (hadError)
return;
@@ -1672,7 +1672,7 @@
= new (SemaRef.Context) InitListExpr(InitRange.getBegin(), 0, 0,
InitRange.getEnd());
- Result->setType(CurrentObjectType);
+ Result->setType(CurrentObjectType.getNonReferenceType());
// Pre-allocate storage for the structured initializer list.
unsigned NumElements = 0;