1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 class Base
{ // expected-warning{{class 'Base' does not declare any constructor to initialize its non-modifiable members}}
6 #if __cplusplus <= 199711L
7 // expected-error@-2 {{cannot define the implicit copy assignment operator for 'Base', because non-static reference member 'ref' cannot use copy assignment operator}}
10 int &ref
; // expected-note{{reference member 'ref' will never be initialized}}
11 #if __cplusplus <= 199711L
12 // expected-note@-2 {{declared here}}
14 // expected-note@-4 2 {{copy assignment operator of 'Base' is implicitly deleted because field 'ref' is of reference type 'int &'}}
19 #if __cplusplus <= 199711L
20 // expected-note@-2 {{assignment operator for 'Base' first required here}}
21 // expected-error@-3 {{cannot define the implicit copy assignment operator for 'X', because non-static const member 'cint' cannot use copy assignment operator}}
23 // expected-note@-5 2 {{copy assignment operator of 'X' is implicitly deleted because base class 'Base' has a deleted copy assignment operator}}
29 #if __cplusplus <= 199711L
30 // expected-note@-2 {{declared here}}
36 Y
& operator=(const Y
&);
37 Y
& operator=(volatile Y
&);
38 Y
& operator=(const volatile Y
&);
48 void f(X x
, const X cx
) {
50 #if __cplusplus <= 199711L
51 // expected-note@-2 2{{assignment operator for 'X' first required here}}
53 // expected-error@-4 {{object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted}}
57 #if __cplusplus >= 201103L
58 // expected-error@-2 {{object of type 'X' cannot be assigned because its copy assignment operator is implicitly deleted}}
91 B1
&operator = (B1 b
);
104 #if __cplusplus <= 199711L
105 // expected-error@-2 {{cannot define the implicit copy assignment operator for 'E1', because non-static const member 'a' cannot use copy assignment operator}}
110 #if __cplusplus <= 199711L
111 // expected-note@-2 {{declared here}}
113 // expected-note@-4 {{copy assignment operator of 'E1' is implicitly deleted because field 'a' is of const-qualified type 'const int'}}
123 #if __cplusplus <= 199711L
124 // expected-note@-2 {{assignment operator for 'E1' first required here}}
126 // expected-error@-4 {{object of type 'E1' cannot be assigned because its copy assignment operator is implicitly deleted}}
130 namespace ProtectedCheck
{
133 X
&operator=(const X
&);
134 #if __cplusplus <= 199711L
135 // expected-note@-2 {{declared protected here}}
139 struct Y
: public X
{ };
141 void f(Y y
) { y
= y
; }
144 #if __cplusplus <= 199711L
145 // expected-error@-2 {{'operator=' is a protected member of 'ProtectedCheck::X'}}
148 #if __cplusplus >= 201103L
149 // expected-note@-2 {{copy assignment operator of 'Z' is implicitly deleted because field 'x' has an inaccessible copy assignment operator}}
153 void f(Z z
) { z
= z
; }
154 #if __cplusplus <= 199711L
155 // expected-note@-2 {{implicit copy assignment operator}}
157 // expected-error@-4 {{object of type 'Z' cannot be assigned because its copy assignment operator is implicitly deleted}}
161 namespace MultiplePaths
{
163 X0
&operator=(const X0
&);
166 struct X1
: public virtual X0
{ };
168 struct X2
: X0
, X1
{ }; // expected-warning{{direct base 'X0' is inaccessible due to ambiguity:\n struct MultiplePaths::X2 -> X0\n struct MultiplePaths::X2 -> X1 -> X0}}
170 void f(X2 x2
) { x2
= x2
; }