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