diff options
-rw-r--r-- | lib/CodeGen/CGClass.cpp | 12 | ||||
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 38 |
2 files changed, 18 insertions, 32 deletions
diff --git a/lib/CodeGen/CGClass.cpp b/lib/CodeGen/CGClass.cpp index 56d0e695c5..966a93c652 100644 --- a/lib/CodeGen/CGClass.cpp +++ b/lib/CodeGen/CGClass.cpp @@ -692,18 +692,6 @@ CodeGenFunction::SynthesizeCXXCopyConstructor(const FunctionArgList &Args) { llvm::Value *SrcPtr = Builder.CreateLoad(GetAddrOfLocalVar(Args[SrcArgIndex].first)); - for (CXXRecordDecl::base_class_const_iterator Base = ClassDecl->bases_begin(); - Base != ClassDecl->bases_end(); ++Base) { - // FIXME. copy constrution of virtual base NYI - if (Base->isVirtual()) - continue; - - CXXRecordDecl *BaseClassDecl - = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); - EmitClassMemberwiseCopy(ThisPtr, SrcPtr, ClassDecl, BaseClassDecl, - Base->getType()); - } - for (CXXRecordDecl::field_iterator I = ClassDecl->field_begin(), E = ClassDecl->field_end(); I != E; ++I) { const FieldDecl *Field = *I; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 2057b9aa0d..6f79a51c84 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -1503,7 +1503,10 @@ BuildImplicitBaseInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, SourceLocation(), ParamType, 0); // Cast to the base class to avoid ambiguities. - SemaRef.ImpCastExprToType(CopyCtorArg, BaseSpec->getType(), + QualType ArgTy = + SemaRef.Context.getQualifiedType(BaseSpec->getType().getUnqualifiedType(), + ParamType.getQualifiers()); + SemaRef.ImpCastExprToType(CopyCtorArg, ArgTy, CastExpr::CK_UncheckedDerivedToBase, /*isLvalue=*/true, CXXBaseSpecifierArray(BaseSpec)); @@ -1545,6 +1548,11 @@ BuildImplicitMemberInitializer(Sema &SemaRef, CXXConstructorDecl *Constructor, FieldDecl *Field, CXXBaseOrMemberInitializer *&CXXMemberInit) { if (ImplicitInitKind == IIK_Copy) { + // FIXME: We should not return early here, but will do so until + // we know how to handle copy initialization of arrays. + CXXMemberInit = 0; + return false; + ParmVarDecl *Param = Constructor->getParamDecl(0); QualType ParamType = Param->getType().getNonReferenceType(); @@ -4212,25 +4220,16 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation, ImplicitlyDefinedFunctionScope Scope(*this, CopyConstructor); - // C++ [class.copy] p209 - // Before the implicitly-declared copy constructor for a class is - // implicitly defined, all the implicitly-declared copy constructors - // for its base class and its non-static data members shall have been - // implicitly defined. - for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(); - Base != ClassDecl->bases_end(); ++Base) { - CXXRecordDecl *BaseClassDecl - = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); - if (CXXConstructorDecl *BaseCopyCtor = - BaseClassDecl->getCopyConstructor(Context, TypeQuals)) { - CheckDirectMemberAccess(Base->getSourceRange().getBegin(), - BaseCopyCtor, - PDiag(diag::err_access_copy_base) - << Base->getType()); - - MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor); - } + if (SetBaseOrMemberInitializers(CopyConstructor, 0, 0, /*AnyErrors=*/false)) { + Diag(CurrentLocation, diag::note_member_synthesized_at) + << CXXCopyConstructor << Context.getTagDeclType(ClassDecl); + CopyConstructor->setInvalidDecl(); + } else { + CopyConstructor->setUsed(); } + + // FIXME: Once SetBaseOrMemberInitializers can handle copy initialization of + // fields, this code below should be removed. for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(), FieldEnd = ClassDecl->field_end(); Field != FieldEnd; ++Field) { @@ -4251,7 +4250,6 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation, } } } - CopyConstructor->setUsed(); } Sema::OwningExprResult |