diff options
author | Anders Carlsson <andersca@mac.com> | 2010-01-23 20:20:40 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-01-23 20:20:40 +0000 |
commit | 2bbae5de98f486d03e10c039668182075b5569dd (patch) | |
tree | 35267e97f56afe56e149131b35a650b5e21d35e9 /lib/Sema/SemaInit.cpp | |
parent | 784f69940755dd66cf244dd84f57a57d358e5c43 (diff) |
Use the new init code for member subobjects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94329 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index a2e45530d2..f7d9305276 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -236,7 +236,8 @@ class InitListChecker { InitListExpr *IList, QualType DeclType, unsigned &Index, InitListExpr *StructuredList, unsigned &StructuredIndex); - void CheckStructUnionTypes(InitListExpr *IList, QualType DeclType, + void CheckStructUnionTypes(const InitializedEntity *Entity, + InitListExpr *IList, QualType DeclType, RecordDecl::field_iterator Field, bool SubobjectIsDesignatorContext, unsigned &Index, InitListExpr *StructuredList, @@ -633,7 +634,7 @@ void InitListChecker::CheckListElementTypes(const InitializedEntity *Entity, } else if (DeclType->isAggregateType()) { if (DeclType->isRecordType()) { RecordDecl *RD = DeclType->getAs<RecordType>()->getDecl(); - CheckStructUnionTypes(IList, DeclType, RD->field_begin(), + CheckStructUnionTypes(Entity, IList, DeclType, RD->field_begin(), SubobjectIsDesignatorContext, Index, StructuredList, StructuredIndex, TopLevelObject); @@ -1060,7 +1061,8 @@ void InitListChecker::CheckArrayType(const InitializedEntity *Entity, } } -void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, +void InitListChecker::CheckStructUnionTypes(const InitializedEntity *Entity, + InitListExpr *IList, QualType DeclType, RecordDecl::field_iterator Field, bool SubobjectIsDesignatorContext, @@ -1138,8 +1140,17 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, continue; } - CheckSubElementType(0, IList, Field->getType(), Index, - StructuredList, StructuredIndex); + // FIXME: Once we know Entity is not null, we can get rid of the check + // and the else block. + if (Entity) { + InitializedEntity MemberEntity = + InitializedEntity::InitializeMember(*Field, Entity); + CheckSubElementType(&MemberEntity, IList, Field->getType(), Index, + StructuredList, StructuredIndex); + } else { + CheckSubElementType(0, IList, Field->getType(), Index, + StructuredList, StructuredIndex); + } InitializedSomething = true; if (DeclType->isUnionType()) { @@ -1549,7 +1560,8 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList, // Check the remaining fields within this class/struct/union subobject. bool prevHadError = hadError; - CheckStructUnionTypes(IList, CurrentObjectType, Field, false, Index, + + CheckStructUnionTypes(0, IList, CurrentObjectType, Field, false, Index, StructuredList, FieldIndex); return hadError && !prevHadError; } |