[cfe-commits] r94332 - /cfe/trunk/lib/Sema/SemaInit.cpp

Anders Carlsson andersca at mac.com
Sat Jan 23 12:47:59 PST 2010


Author: andersca
Date: Sat Jan 23 14:47:59 2010
New Revision: 94332

URL: http://llvm.org/viewvc/llvm-project?rev=94332&view=rev
Log:
More init work, adding more entity parameters.

Modified:
    cfe/trunk/lib/Sema/SemaInit.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=94332&r1=94331&r2=94332&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Sat Jan 23 14:47:59 2010
@@ -202,7 +202,8 @@
   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 @@
   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 @@
 
   // 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 @@
     //   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 @@
       << *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





More information about the cfe-commits mailing list