From 6aee62129150e5fbe34f8d6e8a2e89f03d000d92 Mon Sep 17 00:00:00 2001 From: John McCall Date: Wed, 4 Nov 2009 23:13:52 +0000 Subject: [PATCH] Comments, formatting. Based on patch by Brandon Pearcy! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86065 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index fdbd554e03..5b101247da 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1021,6 +1021,7 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args, // Diagnose value-uses of fields to initialize themselves, e.g. // foo(foo) // where foo is not also a parameter to the constructor. + // TODO: implement -Wuninitialized and fold this into that framework. for (unsigned i = 0; i < NumArgs; ++i) { SourceLocation L; if (InitExprContainsUninitializedFields(Args[i], Member, &L)) { @@ -1044,7 +1045,9 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args, FieldType = Array->getElementType(); if (FieldType->isDependentType()) { // Can't check init for dependent type. - } else if (FieldType->getAs()) { + } else if (FieldType->isRecordType()) { + // Member is a record (struct/union/class), so pass the initializer + // arguments down to the record's constructor. if (!HasDependentArg) { ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(*this); @@ -1064,6 +1067,8 @@ Sema::BuildMemberInitializer(FieldDecl *Member, Expr **Args, } } } else if (NumArgs != 1 && NumArgs != 0) { + // The member type is not a record type (or an array of record + // types), so it can be only be default- or copy-initialized. return Diag(IdLoc, diag::err_mem_initializer_mismatch) << Member->getDeclName() << SourceRange(IdLoc, RParenLoc); } else if (!HasDependentArg) { @@ -1217,7 +1222,7 @@ Sema::SetBaseOrMemberInitializers(CXXConstructorDecl *Constructor, // On seeing one dependent type, we should essentially exit this routine // while preserving user-declared initializer list. When this routine is // called during instantiatiation process, this routine will rebuild the - // oderdered initializer list correctly. + // ordered initializer list correctly. // If we have a dependent base initialization, we can't determine the // association between initializers and bases; just dump the known @@ -1473,6 +1478,7 @@ static void *GetKeyForMember(CXXBaseOrMemberInitializer *Member, return GetKeyForBase(QualType(Member->getBaseClass(), 0)); } +/// ActOnMemInitializers - Handle the member initializers for a constructor. void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, SourceLocation ColonLoc, MemInitTy **MemInits, unsigned NumMemInits) { -- 2.40.0