diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-07-01 18:27:03 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-07-01 18:27:03 +0000 | 
| commit | cfe682274cee000fe8b39131090a27e87e970346 (patch) | |
| tree | 5b50fa410682fb9a88380bc26f8950c6f2a3f353 /clang/lib/Sema/SemaDeclCXX.cpp | |
| parent | 2f1881f6bda7a992f380aa174332769590467207 (diff) | |
| download | bcm5719-llvm-cfe682274cee000fe8b39131090a27e87e970346.tar.gz bcm5719-llvm-cfe682274cee000fe8b39131090a27e87e970346.zip | |
Teach DeclareImplicitCopyConstructor how to cope with virtual bases
and multi-dimensional array fields. Fixes several bugs found by
inspection.
llvm-svn: 107411
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 24 | 
1 files changed, 17 insertions, 7 deletions
| diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 4b7015caec5..d7103219393 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -4915,8 +4915,6 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(Scope *S,    //   If the class definition does not explicitly declare a copy    //   constructor, one is declared implicitly. -  // FIXME: virtual bases! -      // C++ [class.copy]p5:    //   The implicitly-declared copy constructor for a class X will    //   have the form @@ -4933,6 +4931,20 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(Scope *S,                                         BaseEnd = ClassDecl->bases_end();         HasConstCopyConstructor && Base != BaseEnd;          ++Base) { +    // Virtual bases are handled below. +    if (Base->isVirtual()) +      continue; +     +    const CXXRecordDecl *BaseClassDecl +      = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); +    HasConstCopyConstructor +      = BaseClassDecl->hasConstCopyConstructor(Context); +  } + +  for (CXXRecordDecl::base_class_iterator Base = ClassDecl->vbases_begin(), +                                       BaseEnd = ClassDecl->vbases_end(); +       HasConstCopyConstructor && Base != BaseEnd;  +       ++Base) {      const CXXRecordDecl *BaseClassDecl        = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());      HasConstCopyConstructor @@ -4947,14 +4959,12 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor(Scope *S,                                    FieldEnd = ClassDecl->field_end();         HasConstCopyConstructor && Field != FieldEnd;         ++Field) { -    QualType FieldType = (*Field)->getType(); -    if (const ArrayType *Array = Context.getAsArrayType(FieldType)) -      FieldType = Array->getElementType(); +    QualType FieldType = Context.getBaseElementType((*Field)->getType());      if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {        const CXXRecordDecl *FieldClassDecl -      = cast<CXXRecordDecl>(FieldClassType->getDecl()); +        = cast<CXXRecordDecl>(FieldClassType->getDecl());        HasConstCopyConstructor -      = FieldClassDecl->hasConstCopyConstructor(Context); +        = FieldClassDecl->hasConstCopyConstructor(Context);      }    } | 

