diff options
Diffstat (limited to 'test/CXX/special/class.copy/p18-cxx11.cpp')
-rw-r--r-- | test/CXX/special/class.copy/p18-cxx11.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/CXX/special/class.copy/p18-cxx11.cpp b/test/CXX/special/class.copy/p18-cxx11.cpp new file mode 100644 index 0000000..7b09dd6 --- /dev/null +++ b/test/CXX/special/class.copy/p18-cxx11.cpp @@ -0,0 +1,62 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify +// expected-no-diagnostics + +// C++98 [class.copy]p10 / C++11 [class.copy]p18. + +// The implicitly-declared copy assignment operator for a class X will have the form +// X& X::operator=(const X&) +// if [every direct subobject] has a copy assignment operator whose first parameter is +// of type 'const volatile[opt] T &' or 'T'. Otherwise, it will have the form +// X &X::operator=(X&) + +struct ConstCopy { + ConstCopy &operator=(const ConstCopy &); +}; + +struct NonConstCopy { + NonConstCopy &operator=(NonConstCopy &); +}; + +struct DeletedConstCopy { + DeletedConstCopy &operator=(const DeletedConstCopy &) = delete; +}; + +struct DeletedNonConstCopy { + DeletedNonConstCopy &operator=(DeletedNonConstCopy &) = delete; +}; + +struct ImplicitlyDeletedConstCopy { + ImplicitlyDeletedConstCopy &operator=(ImplicitlyDeletedConstCopy &&); +}; + +struct ByValueCopy { + ByValueCopy &operator=(ByValueCopy); +}; + +struct AmbiguousConstCopy { + AmbiguousConstCopy &operator=(const AmbiguousConstCopy&); + AmbiguousConstCopy &operator=(AmbiguousConstCopy); +}; + + +struct A : ConstCopy {}; +struct B : NonConstCopy { ConstCopy a; }; +struct C : ConstCopy { NonConstCopy a; }; +struct D : DeletedConstCopy {}; +struct E : DeletedNonConstCopy {}; +struct F { ImplicitlyDeletedConstCopy a; }; +struct G : virtual B {}; +struct H : ByValueCopy {}; +struct I : AmbiguousConstCopy {}; + +struct Test { + friend A &A::operator=(const A &); + friend B &B::operator=(B &); + friend C &C::operator=(C &); + friend D &D::operator=(const D &); + friend E &E::operator=(E &); + friend F &F::operator=(const F &); + friend G &G::operator=(G &); + friend H &H::operator=(const H &); + friend I &I::operator=(const I &); +}; |