diff options
author | Anders Carlsson <andersca@mac.com> | 2010-01-23 20:47:59 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2010-01-23 20:47:59 +0000 |
commit | dbb25a38b99c21f4e6af4ffcae47c81e7e3184b2 (patch) | |
tree | bcdbbfe69b605b8c59130956a7d29a74c026a9c7 /clang/lib/Sema | |
parent | 7e7ed8b9e53a594cc629ba5a98f909a35490c525 (diff) | |
download | bcm5719-llvm-dbb25a38b99c21f4e6af4ffcae47c81e7e3184b2.tar.gz bcm5719-llvm-dbb25a38b99c21f4e6af4ffcae47c81e7e3184b2.zip |
More init work, adding more entity parameters.
llvm-svn: 94332
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index f7d93052760..7c150db5995 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -202,7 +202,8 @@ class InitListChecker { std::map<InitListExpr *, InitListExpr *> SyntacticToSemantic; InitListExpr *FullyStructuredList; - void CheckImplicitInitList(InitListExpr *ParentIList, QualType T, + void CheckImplicitInitList(const InitializedEntity *Entity, + InitListExpr *ParentIList, QualType T, unsigned &Index, InitListExpr *StructuredList, unsigned &StructuredIndex, bool TopLevelObject = false); @@ -506,7 +507,8 @@ int InitListChecker::numStructUnionElements(QualType DeclType) { return InitializableMembers - structDecl->hasFlexibleArrayMember(); } -void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList, +void InitListChecker::CheckImplicitInitList(const InitializedEntity *Entity, + InitListExpr *ParentIList, QualType T, unsigned &Index, InitListExpr *StructuredList, unsigned &StructuredIndex, @@ -540,7 +542,8 @@ void InitListChecker::CheckImplicitInitList(InitListExpr *ParentIList, // Check the element types and build the structural subobject. unsigned StartIndex = Index; - CheckListElementTypes(0, ParentIList, T, false, Index, + CheckListElementTypes(Entity, ParentIList, T, + /*SubobjectIsDesignatorContext=*/false, Index, StructuredSubobjectInitList, StructuredSubobjectInitIndex, TopLevelObject); @@ -750,7 +753,7 @@ void InitListChecker::CheckSubElementType(const InitializedEntity *Entity, // considered for the initialization of the first member of // the subaggregate. if (ElemType->isAggregateType() || ElemType->isVectorType()) { - CheckImplicitInitList(IList, ElemType, Index, StructuredList, + CheckImplicitInitList(Entity, IList, ElemType, Index, StructuredList, StructuredIndex); ++StructuredIndex; } else { @@ -1185,12 +1188,26 @@ void InitListChecker::CheckStructUnionTypes(const InitializedEntity *Entity, << *Field; } - if (isa<InitListExpr>(IList->getInit(Index))) - CheckSubElementType(0, IList, Field->getType(), Index, StructuredList, - StructuredIndex); - else - CheckImplicitInitList(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); + + if (isa<InitListExpr>(IList->getInit(Index))) + CheckSubElementType(&MemberEntity, IList, Field->getType(), Index, + StructuredList, StructuredIndex); + else + CheckImplicitInitList(&MemberEntity, IList, Field->getType(), Index, + StructuredList, StructuredIndex); + } else { + if (isa<InitListExpr>(IList->getInit(Index))) + CheckSubElementType(0, IList, Field->getType(), Index, + StructuredList, StructuredIndex); + else + CheckImplicitInitList(0, IList, Field->getType(), Index, + StructuredList, StructuredIndex); + } } /// \brief Expand a field designator that refers to a member of an |