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