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