diff options
Diffstat (limited to 'clang/test')
-rw-r--r-- | clang/test/CXX/special/class.copy/p18-cxx11.cpp | 62 | ||||
-rw-r--r-- | clang/test/PCH/Inputs/cxx-method.h | 3 | ||||
-rw-r--r-- | clang/test/PCH/cxx-method.cpp | 6 |
3 files changed, 71 insertions, 0 deletions
diff --git a/clang/test/CXX/special/class.copy/p18-cxx11.cpp b/clang/test/CXX/special/class.copy/p18-cxx11.cpp new file mode 100644 index 00000000000..7b09dd679f2 --- /dev/null +++ b/clang/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 &); +}; diff --git a/clang/test/PCH/Inputs/cxx-method.h b/clang/test/PCH/Inputs/cxx-method.h index 6adb8591707..d5d56fed058 100644 --- a/clang/test/PCH/Inputs/cxx-method.h +++ b/clang/test/PCH/Inputs/cxx-method.h @@ -1,6 +1,9 @@ struct S { void m(int x); + S(); + S(const S&); + operator const char*(); operator char*(); }; diff --git a/clang/test/PCH/cxx-method.cpp b/clang/test/PCH/cxx-method.cpp index 40490ea681f..c24ad929758 100644 --- a/clang/test/PCH/cxx-method.cpp +++ b/clang/test/PCH/cxx-method.cpp @@ -1,3 +1,4 @@ +// RUN: %clang_cc1 -x c++ -include %S/Inputs/cxx-method.h -verify %s // RUN: %clang_cc1 -x c++ -emit-pch %S/Inputs/cxx-method.h -o %t // RUN: %clang_cc1 -include-pch %t -verify %s // expected-no-diagnostics @@ -7,3 +8,8 @@ void S::m(int x) { } S::operator char *() { return 0; } S::operator const char *() { return 0; } + +struct T : S {}; + +const T a = T(); +T b(a); |