diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-07-01 17:48:08 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-07-01 17:48:08 +0000 | 
| commit | 68e1136585a4ffc2187c68f3a9a88115bd0ce0ae (patch) | |
| tree | 5c6ca43f81aff97e73082ac7405bd4d60228aece /clang/lib/Sema/SemaDeclCXX.cpp | |
| parent | 5e88700f284ab6ac3a05033a65b801a509662e51 (diff) | |
| download | bcm5719-llvm-68e1136585a4ffc2187c68f3a9a88115bd0ce0ae.tar.gz bcm5719-llvm-68e1136585a4ffc2187c68f3a9a88115bd0ce0ae.zip | |
Provide an exception-specification for an implicitly-declared
copy-assignment operator.
llvm-svn: 107406
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 33 | 
1 files changed, 31 insertions, 2 deletions
| diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 130aa576b67..9d18e177fd5 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -4626,6 +4626,33 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(Scope *S,      ArgType = ArgType.withConst();    ArgType = Context.getLValueReferenceType(ArgType); +  // C++ [except.spec]p14: +  //   An implicitly declared special member function (Clause 12) shall have an  +  //   exception-specification. [...] +  ImplicitExceptionSpecification ExceptSpec(Context); +  for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(), +                                       BaseEnd = ClassDecl->bases_end(); +       Base != BaseEnd; ++Base) { +    const CXXRecordDecl *BaseClassDecl +      = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl()); +    if (CXXMethodDecl *CopyAssign +           = BaseClassDecl->getCopyAssignmentOperator(HasConstCopyAssignment)) +      ExceptSpec.CalledDecl(CopyAssign); +  } +  for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(), +                                  FieldEnd = ClassDecl->field_end(); +       Field != FieldEnd; +       ++Field) { +    QualType FieldType = Context.getBaseElementType((*Field)->getType()); +    if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) { +      const CXXRecordDecl *FieldClassDecl +        = cast<CXXRecordDecl>(FieldClassType->getDecl()); +      if (CXXMethodDecl *CopyAssign +            = FieldClassDecl->getCopyAssignmentOperator(HasConstCopyAssignment)) +        ExceptSpec.CalledDecl(CopyAssign);       +    }       +  } +      //   An implicitly-declared copy assignment operator is an inline public    //   member of its class.    DeclarationName Name = Context.DeclarationNames.getCXXOperatorName(OO_Equal); @@ -4633,8 +4660,10 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(Scope *S,      = CXXMethodDecl::Create(Context, ClassDecl, ClassDecl->getLocation(), Name,                              Context.getFunctionType(RetType, &ArgType, 1,                                                      false, 0, -                                              /*FIXME: hasExceptionSpec*/false, -                                                    false, 0, 0, +                                         ExceptSpec.hasExceptionSpecification(), +                                      ExceptSpec.hasAnyExceptionSpecification(), +                                                    ExceptSpec.size(), +                                                    ExceptSpec.data(),                                                      FunctionType::ExtInfo()),                              /*TInfo=*/0, /*isStatic=*/false,                              /*StorageClassAsWritten=*/FunctionDecl::None, | 

