aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-01-23 20:13:41 +0000
committerAnders Carlsson <andersca@mac.com>2010-01-23 20:13:41 +0000
commit784f69940755dd66cf244dd84f57a57d358e5c43 (patch)
tree28793206eaaa39fc602e40179b92b9ef8b1e9cce /lib/Sema/SemaInit.cpp
parent46171917dc87caf0c7a741a7301f36db2e20b132 (diff)
Switch some array initialization over to the new init code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94327 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp29
1 files changed, 22 insertions, 7 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 0f4ba7c028..a2e45530d2 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -242,7 +242,8 @@ class InitListChecker {
InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject = false);
- void CheckArrayType(InitListExpr *IList, QualType &DeclType,
+ void CheckArrayType(const InitializedEntity *Entity,
+ InitListExpr *IList, QualType &DeclType,
llvm::APSInt elementIndex,
bool SubobjectIsDesignatorContext, unsigned &Index,
InitListExpr *StructuredList,
@@ -640,7 +641,8 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity *Entity,
llvm::APSInt Zero(
SemaRef.Context.getTypeSize(SemaRef.Context.getSizeType()),
false);
- CheckArrayType(IList, DeclType, Zero, SubobjectIsDesignatorContext, Index,
+ CheckArrayType(Entity, IList, DeclType, Zero,
+ SubobjectIsDesignatorContext, Index,
StructuredList, StructuredIndex);
} else
assert(0 && "Aggregate that isn't a structure or array?!");
@@ -932,7 +934,8 @@ void InitListChecker::CheckVectorType(const InitializedEntity *Entity,
}
}
-void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
+void InitListChecker::CheckArrayType(const InitializedEntity *Entity,
+ InitListExpr *IList, QualType &DeclType,
llvm::APSInt elementIndex,
bool SubobjectIsDesignatorContext,
unsigned &Index,
@@ -1020,9 +1023,20 @@ void InitListChecker::CheckArrayType(InitListExpr *IList, QualType &DeclType,
if (maxElementsKnown && elementIndex == maxElements)
break;
- // Check this element.
- CheckSubElementType(0, IList, elementType, Index,
- StructuredList, StructuredIndex);
+ // FIXME: Once we know that Entity is not null, we can remove this check,
+ // and the else block.
+ if (Entity) {
+ InitializedEntity ElementEntity =
+ InitializedEntity::InitializeElement(SemaRef.Context, StructuredIndex,
+ *Entity);
+ // Check this element.
+ CheckSubElementType(&ElementEntity, IList, elementType, Index,
+ StructuredList, StructuredIndex);
+ } else {
+ // Check this element.
+ CheckSubElementType(0, IList, elementType, Index,
+ StructuredList, StructuredIndex);
+ }
++elementIndex;
// If the array is of incomplete type, keep track of the number of
@@ -1649,7 +1663,8 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
// Check the remaining elements within this array subobject.
bool prevHadError = hadError;
- CheckArrayType(IList, CurrentObjectType, DesignatedStartIndex, false, Index,
+ CheckArrayType(0, IList, CurrentObjectType, DesignatedStartIndex,
+ /*SubobjectIsDesignatorContext=*/false, Index,
StructuredList, ElementIndex);
return hadError && !prevHadError;
}