1// RUN: %clang_cc1 -std=c++11 %s -verify 2// expected-no-diagnostics 3 4// C++98 [class.copy]p10 / C++11 [class.copy]p18. 5 6// The implicitly-declared copy assignment operator for a class X will have the form 7// X& X::operator=(const X&) 8// if [every direct subobject] has a copy assignment operator whose first parameter is 9// of type 'const volatile[opt] T &' or 'T'. Otherwise, it will have the form 10// X &X::operator=(X&) 11 12struct ConstCopy { 13 ConstCopy &operator=(const ConstCopy &); 14}; 15 16struct NonConstCopy { 17 NonConstCopy &operator=(NonConstCopy &); 18}; 19 20struct DeletedConstCopy { 21 DeletedConstCopy &operator=(const DeletedConstCopy &) = delete; 22}; 23 24struct DeletedNonConstCopy { 25 DeletedNonConstCopy &operator=(DeletedNonConstCopy &) = delete; 26}; 27 28struct ImplicitlyDeletedConstCopy { 29 ImplicitlyDeletedConstCopy &operator=(ImplicitlyDeletedConstCopy &&); 30}; 31 32struct ByValueCopy { 33 ByValueCopy &operator=(ByValueCopy); 34}; 35 36struct AmbiguousConstCopy { 37 AmbiguousConstCopy &operator=(const AmbiguousConstCopy&); 38 AmbiguousConstCopy &operator=(AmbiguousConstCopy); 39}; 40 41 42struct A : ConstCopy {}; 43struct B : NonConstCopy { ConstCopy a; }; 44struct C : ConstCopy { NonConstCopy a; }; 45struct D : DeletedConstCopy {}; 46struct E : DeletedNonConstCopy {}; 47struct F { ImplicitlyDeletedConstCopy a; }; 48struct G : virtual B {}; 49struct H : ByValueCopy {}; 50struct I : AmbiguousConstCopy {}; 51 52struct Test { 53 friend A &A::operator=(const A &); 54 friend B &B::operator=(B &); 55 friend C &C::operator=(C &); 56 friend D &D::operator=(const D &); 57 friend E &E::operator=(E &); 58 friend F &F::operator=(const F &); 59 friend G &G::operator=(G &); 60 friend H &H::operator=(const H &); 61 friend I &I::operator=(const I &); 62}; 63