aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaInit.cpp
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2010-01-23 22:49:02 +0000
committerAnders Carlsson <andersca@mac.com>2010-01-23 22:49:02 +0000
commit9a8a70ef79f68db5b17d505eb9681bf161384fe8 (patch)
tree8630378bf582416acfb0754c18bb605fdda56aa3 /lib/Sema/SemaInit.cpp
parent3b85ecf2049c8670eba30d0c06f28f64168af9b8 (diff)
Start passing InitializedEntity to CheckDesignatedInitializer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94334 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r--lib/Sema/SemaInit.cpp31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 7c150db599..b13c4ad299 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -250,7 +250,8 @@ class InitListChecker {
bool SubobjectIsDesignatorContext, unsigned &Index,
InitListExpr *StructuredList,
unsigned &StructuredIndex);
- bool CheckDesignatedInitializer(InitListExpr *IList, DesignatedInitExpr *DIE,
+ bool CheckDesignatedInitializer(const InitializedEntity *Entity,
+ InitListExpr *IList, DesignatedInitExpr *DIE,
unsigned DesigIdx,
QualType &CurrentObjectType,
RecordDecl::field_iterator *NextField,
@@ -1000,7 +1001,7 @@ void InitListChecker::CheckArrayType(const InitializedEntity *Entity,
// Handle this designated initializer. elementIndex will be
// updated to be the next array element we'll initialize.
- if (CheckDesignatedInitializer(IList, DIE, 0,
+ if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
DeclType, 0, &elementIndex, Index,
StructuredList, StructuredIndex, true,
false)) {
@@ -1114,7 +1115,7 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity *Entity,
// Handle this designated initializer. Field will be updated to
// the next field that we'll be initializing.
- if (CheckDesignatedInitializer(IList, DIE, 0,
+ if (CheckDesignatedInitializer(Entity, IList, DIE, 0,
DeclType, &Field, 0, Index,
StructuredList, StructuredIndex,
true, TopLevelObject))
@@ -1304,7 +1305,8 @@ static void ExpandAnonymousFieldDesignator(Sema &SemaRef,
///
/// @returns true if there was an error, false otherwise.
bool
-InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
+InitListChecker::CheckDesignatedInitializer(const InitializedEntity *Entity,
+ InitListExpr *IList,
DesignatedInitExpr *DIE,
unsigned DesigIdx,
QualType &CurrentObjectType,
@@ -1325,7 +1327,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
unsigned OldIndex = Index;
IList->setInit(OldIndex, DIE->getInit());
- CheckSubElementType(0, IList, CurrentObjectType, Index,
+ CheckSubElementType(Entity, IList, CurrentObjectType, Index,
StructuredList, StructuredIndex);
// Restore the designated initializer expression in the syntactic
@@ -1548,8 +1550,12 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
// Recurse to check later designated subobjects.
QualType FieldType = (*Field)->getType();
unsigned newStructuredIndex = FieldIndex;
- if (CheckDesignatedInitializer(IList, DIE, DesigIdx + 1, FieldType, 0, 0,
- Index, StructuredList, newStructuredIndex,
+
+ InitializedEntity MemberEntity =
+ InitializedEntity::InitializeMember(*Field, Entity);
+ if (CheckDesignatedInitializer(&MemberEntity, IList, DIE, DesigIdx + 1,
+ FieldType, 0, 0, Index,
+ StructuredList, newStructuredIndex,
true, false))
return true;
}
@@ -1663,12 +1669,19 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList,
// Move to the next designator
unsigned ElementIndex = DesignatedStartIndex.getZExtValue();
unsigned OldIndex = Index;
+
+ InitializedEntity ElementEntity =
+ InitializedEntity::InitializeElement(SemaRef.Context, 0, *Entity);
+
while (DesignatedStartIndex <= DesignatedEndIndex) {
// Recurse to check later designated subobjects.
QualType ElementType = AT->getElementType();
Index = OldIndex;
- if (CheckDesignatedInitializer(IList, DIE, DesigIdx + 1, ElementType, 0, 0,
- Index, StructuredList, ElementIndex,
+
+ ElementEntity.setElementIndex(ElementIndex);
+ if (CheckDesignatedInitializer(&ElementEntity, IList, DIE, DesigIdx + 1,
+ ElementType, 0, 0, Index,
+ StructuredList, ElementIndex,
(DesignatedStartIndex == DesignatedEndIndex),
false))
return true;