blob: e627fefdef6ddefb0991cdbb90d20efa3e0e6bcd [file] [log] [blame]
Fariborz Jahaniana1fbe862009-06-25 22:40:36 +00001// RUN: clang-cc -fsyntax-only -verify %s
2
3class 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
8class X : Base { // // expected-error {{cannot define the implicit default assignment operator for 'class X'}}
9public:
10 X();
11 const int cint; // expected-note {{declared at}}
12};
13
14struct 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
22class Z : Y {};
23
24Z z1;
25Z z2;
26
27// Test1
28void f(X x, const X cx) {
Mike Stump1eb44332009-09-09 15:08:12 +000029 x = cx; // expected-note {{synthesized method is first required here}}
Fariborz Jahaniana1fbe862009-06-25 22:40:36 +000030 x = cx;
31 z1 = z2;
32}
33
34// Test2
35class T {};
36T t1;
37T t2;
38
Mike Stump1eb44332009-09-09 15:08:12 +000039void g() {
Fariborz Jahaniana1fbe862009-06-25 22:40:36 +000040 t1 = t2;
41}
42
43// Test3
44class V {
45public:
46 V();
47 V &operator = (V &b);
48};
49
50class W : V {};
51W w1, w2;
52
Mike Stump1eb44332009-09-09 15:08:12 +000053void h() {
Fariborz Jahaniana1fbe862009-06-25 22:40:36 +000054 w1 = w2;
55}
56
57// Test4
58
59class B1 {
60public:
61 B1();
62 B1 &operator = (B1 b);
63};
64
65class D1 : B1 {};
66D1 d1, d2;
67
Mike Stump1eb44332009-09-09 15:08:12 +000068void i() {
69 d1 = d2;
Fariborz Jahaniana1fbe862009-06-25 22:40:36 +000070}
71
Anders Carlsson5e09d4c2009-07-09 17:47:25 +000072// Test5
73
74class 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}}
75public:
76 const int a; // expected-note{{declared at}}
77 E1() : a(0) {}
78
79};
80
81E1 e1, e2;
82
Mike Stump1eb44332009-09-09 15:08:12 +000083void j() {
Anders Carlsson5e09d4c2009-07-09 17:47:25 +000084 e1 = e2; // expected-note{{synthesized method is first required here}}
85}
86