]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaCXX/default-assignment-operator.cpp
Update clang to r100181.
[FreeBSD/FreeBSD.git] / test / SemaCXX / default-assignment-operator.cpp
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2
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}}
4   int &ref;  // expected-note {{declared at}}
5 };
6
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}}
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) {
28   x = cx;  // expected-note 2 {{synthesized method is first required here}}
29   x = cx;
30   z1 = z2;
31 }
32
33 // Test2
34 class T {};
35 T t1;
36 T t2;
37
38 void g() {
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
52 void h() {
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
67 void i() {
68   d1 = d2;
69 }
70
71 // Test5
72
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}}
74 public:
75   const int a; // expected-note{{declared at}}
76   E1() : a(0) {}  
77
78 };
79
80 E1 e1, e2;
81
82 void j() {
83   e1 = e2; // expected-note{{synthesized method is first required here}}
84 }
85