diff options
author | Bill Wendling <isanbard@gmail.com> | 2012-05-12 00:28:35 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2012-05-12 00:28:35 +0000 |
commit | e2f692bd189cfdf562175b786fe92c87ecdfcbfb (patch) | |
tree | 7e87711c6f0f484373ffa378964b34d7e0c8eb52 /test/CXX/special/class.copy/p8-cxx11.cpp | |
parent | 0b3707c66993e57868b5480e79a9e0707c987dc0 (diff) |
Merging r155218:
------------------------------------------------------------------------
r155218 | rsmith | 2012-04-20 11:46:14 -0700 (Fri, 20 Apr 2012) | 5 lines
Fix bug where a class's (deleted) copy constructor would be implicitly given a
non-const reference parameter type if the class had any subobjects with deleted
copy constructors. This causes a rejects-valid if the class's copy constructor
is explicitly defaulted (as happens for some implementations of std::pair etc).
------------------------------------------------------------------------
git-svn-id: https://llvm.org/svn/llvm-project/cfe/branches/release_31@156682 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/special/class.copy/p8-cxx11.cpp')
-rw-r--r-- | test/CXX/special/class.copy/p8-cxx11.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/CXX/special/class.copy/p8-cxx11.cpp b/test/CXX/special/class.copy/p8-cxx11.cpp new file mode 100644 index 0000000000..02e6cd1c9a --- /dev/null +++ b/test/CXX/special/class.copy/p8-cxx11.cpp @@ -0,0 +1,48 @@ +// RUN: %clang_cc1 -std=c++11 %s -verify + +// C++98 [class.copy]p5 / C++11 [class.copy]p8. + +// The implicitly-declared copy constructor for a class X will have the form +// X::X(const X&) +// if [every direct subobject] has a copy constructor whose first parameter is +// of type 'const volatile[opt] T &'. Otherwise, it will have the form +// X::X(X&) + +struct ConstCopy { + ConstCopy(const ConstCopy &); +}; + +struct NonConstCopy { + NonConstCopy(NonConstCopy &); +}; + +struct DeletedConstCopy { + DeletedConstCopy(const DeletedConstCopy &) = delete; +}; + +struct DeletedNonConstCopy { + DeletedNonConstCopy(DeletedNonConstCopy &) = delete; +}; + +struct ImplicitlyDeletedConstCopy { + ImplicitlyDeletedConstCopy(ImplicitlyDeletedConstCopy &&); +}; + + +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 Test { + friend A::A(const A &); + friend B::B(B &); + friend C::C(C &); + friend D::D(const D &); + friend E::E(E &); + friend F::F(const F &); + friend G::G(G &); +}; |