diff options
author | Nico Weber <nicolasweber@gmx.de> | 2012-01-23 03:19:29 +0000 |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2012-01-23 03:19:29 +0000 |
commit | afcc96a20029ac9009feefbc555a4f9d923e3e06 (patch) | |
tree | e623e4b0c2d6249b2e2f80735182686dadad1098 /lib/Sema/SemaDeclCXX.cpp | |
parent | 8c382060c9e6668a94f1485dd16f012cda526c5f (diff) |
In ms mode, a move assignment operator shouldn't mark a copy ctor as deleted.
MSVC2010's pair class has a move assignment operator but no explicit copy
constructor, which makes it unusable without this change.
For symmetry, let move copy constructors not mark the default assignment
operator as deleted either. Both changes match cl.exe's behavior. Fixes
pr11826.
Also update the standard excerpt to point to the right paragraph.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclCXX.cpp')
-rw-r--r-- | lib/Sema/SemaDeclCXX.cpp | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 6a24d9e430..1371b35ed4 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -7846,12 +7846,14 @@ CXXMethodDecl *Sema::DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl) { PushOnScopeChains(CopyAssignment, S, false); ClassDecl->addDecl(CopyAssignment); - // C++0x [class.copy]p18: - // ... If the class definition declares a move constructor or move - // assignment operator, the implicitly declared copy assignment operator is - // defined as deleted; ... - if (ClassDecl->hasUserDeclaredMoveConstructor() || - ClassDecl->hasUserDeclaredMoveAssignment() || + // C++0x [class.copy]p19: + // .... If the class definition does not explicitly declare a copy + // assignment operator, there is no user-declared move constructor, and + // there is no user-declared move assignment operator, a copy assignment + // operator is implicitly declared as defaulted. + if ((ClassDecl->hasUserDeclaredMoveConstructor() && + !getLangOptions().MicrosoftExt) || + ClassDecl->hasUserDeclaredMoveAssignment() && ShouldDeleteCopyAssignmentOperator(CopyAssignment)) CopyAssignment->setDeletedAsWritten(); @@ -8749,12 +8751,14 @@ CXXConstructorDecl *Sema::DeclareImplicitCopyConstructor( PushOnScopeChains(CopyConstructor, S, false); ClassDecl->addDecl(CopyConstructor); - // C++0x [class.copy]p7: - // ... If the class definition declares a move constructor or move - // assignment operator, the implicitly declared constructor is defined as - // deleted; ... + // C++11 [class.copy]p8: + // ... If the class definition does not explicitly declare a copy + // constructor, there is no user-declared move constructor, and there is no + // user-declared move assignment operator, a copy constructor is implicitly + // declared as defaulted. if (ClassDecl->hasUserDeclaredMoveConstructor() || - ClassDecl->hasUserDeclaredMoveAssignment() || + (ClassDecl->hasUserDeclaredMoveAssignment() && + !getLangOptions().MicrosoftExt) || ShouldDeleteSpecialMember(CopyConstructor, CXXCopyConstructor)) CopyConstructor->setDeletedAsWritten(); |