Add constructor used to initialize base/member in
CXXBaseOrMemberInitializer AST node. Needed by
its clients to do the initialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76826 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 3bb1657..c12878c 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -717,9 +717,17 @@
     // FIXME: Handle members of an anonymous union.
 
     if (Member) {
+      CXXConstructorDecl *C = 0;
+      QualType FieldType = Member->getType();
+      if (const ArrayType *Array = Context.getAsArrayType(FieldType))
+        FieldType = Array->getElementType();
+      if (!FieldType->isDependentType() && FieldType->getAsRecordType())
+        C = PerformInitializationByConstructor(
+              FieldType, (Expr **)Args, NumArgs, IdLoc, 
+              SourceRange(IdLoc, RParenLoc), Member->getDeclName(), IK_Direct);
       // FIXME: Perform direct initialization of the member.
       return new (Context) CXXBaseOrMemberInitializer(Member, (Expr **)Args, 
-                                                      NumArgs, IdLoc);
+                                                      NumArgs, C, IdLoc);
     }
   }
   // It didn't name a member, so see if it names a class.
@@ -789,10 +797,17 @@
     return Diag(IdLoc, diag::err_not_direct_base_or_virtual)
     << BaseType << ClassDecl->getNameAsCString()
     << SourceRange(IdLoc, RParenLoc);
-    
-
-  return new (Context) CXXBaseOrMemberInitializer(BaseType, (Expr **)Args, 
-                                                  NumArgs, IdLoc);
+  DeclarationName Name 
+    = Context.DeclarationNames.getCXXConstructorName(
+        Context.getCanonicalType(BaseType));
+  CXXConstructorDecl *C = 0;
+  if (!BaseType->isDependentType())
+    C = PerformInitializationByConstructor(BaseType, (Expr **)Args, NumArgs, IdLoc, 
+                                       SourceRange(IdLoc, RParenLoc), Name,
+                                       IK_Direct);
+  
+  return new (Context) CXXBaseOrMemberInitializer(BaseType, (Expr **)Args,
+                                                  NumArgs, C, IdLoc);
 }
 
 static void *GetKeyForTopLevelField(FieldDecl *Field) {