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