Fariborz Jahanian | a1fbe86 | 2009-06-25 22:40:36 +0000 | [diff] [blame] | 1 | // RUN: clang-cc -fsyntax-only -verify %s |
| 2 | |
| 3 | class Base { // expected-error {{cannot define the implicit default assignment operator for 'class Base'}} \ |
| 4 | // expected-note {{synthesized method is first required here}} |
| 5 | int &ref; // expected-note {{declared at}} |
| 6 | }; |
| 7 | |
| 8 | class X : Base { // // expected-error {{cannot define the implicit default assignment operator for 'class X'}} |
| 9 | public: |
| 10 | X(); |
| 11 | const int cint; // expected-note {{declared at}} |
| 12 | }; |
| 13 | |
| 14 | struct Y : X { |
| 15 | Y(); |
| 16 | Y& operator=(const Y&); |
| 17 | Y& operator=(volatile Y&); |
| 18 | Y& operator=(const volatile Y&); |
| 19 | Y& operator=(Y&); |
| 20 | }; |
| 21 | |
| 22 | class Z : Y {}; |
| 23 | |
| 24 | Z z1; |
| 25 | Z z2; |
| 26 | |
| 27 | // Test1 |
| 28 | void f(X x, const X cx) { |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 29 | x = cx; // expected-note {{synthesized method is first required here}} |
Fariborz Jahanian | a1fbe86 | 2009-06-25 22:40:36 +0000 | [diff] [blame] | 30 | x = cx; |
| 31 | z1 = z2; |
| 32 | } |
| 33 | |
| 34 | // Test2 |
| 35 | class T {}; |
| 36 | T t1; |
| 37 | T t2; |
| 38 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 39 | void g() { |
Fariborz Jahanian | a1fbe86 | 2009-06-25 22:40:36 +0000 | [diff] [blame] | 40 | t1 = t2; |
| 41 | } |
| 42 | |
| 43 | // Test3 |
| 44 | class V { |
| 45 | public: |
| 46 | V(); |
| 47 | V &operator = (V &b); |
| 48 | }; |
| 49 | |
| 50 | class W : V {}; |
| 51 | W w1, w2; |
| 52 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 53 | void h() { |
Fariborz Jahanian | a1fbe86 | 2009-06-25 22:40:36 +0000 | [diff] [blame] | 54 | w1 = w2; |
| 55 | } |
| 56 | |
| 57 | // Test4 |
| 58 | |
| 59 | class B1 { |
| 60 | public: |
| 61 | B1(); |
| 62 | B1 &operator = (B1 b); |
| 63 | }; |
| 64 | |
| 65 | class D1 : B1 {}; |
| 66 | D1 d1, d2; |
| 67 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 68 | void i() { |
| 69 | d1 = d2; |
Fariborz Jahanian | a1fbe86 | 2009-06-25 22:40:36 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Anders Carlsson | 5e09d4c | 2009-07-09 17:47:25 +0000 | [diff] [blame] | 72 | // Test5 |
| 73 | |
| 74 | class E1 { // expected-error{{cannot define the implicit default assignment operator for 'class E1', because non-static const member 'a' can't use default assignment operator}} |
| 75 | public: |
| 76 | const int a; // expected-note{{declared at}} |
| 77 | E1() : a(0) {} |
| 78 | |
| 79 | }; |
| 80 | |
| 81 | E1 e1, e2; |
| 82 | |
Mike Stump | 1eb4433 | 2009-09-09 15:08:12 +0000 | [diff] [blame] | 83 | void j() { |
Anders Carlsson | 5e09d4c | 2009-07-09 17:47:25 +0000 | [diff] [blame] | 84 | e1 = e2; // expected-note{{synthesized method is first required here}} |
| 85 | } |
| 86 | |