1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
3 
4 struct ConstCopy {
5   ConstCopy();
6   ConstCopy &operator=(const ConstCopy&);
7 };
8 
9 struct NonConstCopy {
10   NonConstCopy();
11   NonConstCopy &operator=(NonConstCopy&);
12 };
13 
14 struct VirtualInheritsNonConstCopy : virtual NonConstCopy {
15   VirtualInheritsNonConstCopy();
16   VirtualInheritsNonConstCopy &operator=(const VirtualInheritsNonConstCopy&);
17 };
18 
19 struct ImplicitNonConstCopy1 : NonConstCopy {  // expected-note{{the implicit copy assignment operator}}
20   ImplicitNonConstCopy1();
21 };
22 
23 struct ImplicitNonConstCopy2 { // expected-note{{the implicit copy assignment operator}}
24   ImplicitNonConstCopy2();
25   NonConstCopy ncc;
26 };
27 
28 struct ImplicitNonConstCopy3 { // expected-note{{the implicit copy assignment operator}}
29   ImplicitNonConstCopy3();
30   NonConstCopy ncc_array[2][3];
31 };
32 
33 struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy {
34   ImplicitNonConstCopy4();
35 };
36 
test_non_const_copy(const ImplicitNonConstCopy1 & cincc1,const ImplicitNonConstCopy2 & cincc2,const ImplicitNonConstCopy3 & cincc3,const ImplicitNonConstCopy4 & cincc4,const VirtualInheritsNonConstCopy & vincc)37 void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,
38                          const ImplicitNonConstCopy2 &cincc2,
39                          const ImplicitNonConstCopy3 &cincc3,
40                          const ImplicitNonConstCopy4 &cincc4,
41                          const VirtualInheritsNonConstCopy &vincc) {
42   (void)sizeof(ImplicitNonConstCopy1() = cincc1); // expected-error{{no viable overloaded '='}}
43   (void)sizeof(ImplicitNonConstCopy2() = cincc2); // expected-error{{no viable overloaded '='}}
44   (void)sizeof(ImplicitNonConstCopy3() = cincc3); // expected-error{{no viable overloaded '='}}
45   (void)sizeof(ImplicitNonConstCopy4() = cincc4); // okay
46   (void)sizeof(VirtualInheritsNonConstCopy() = vincc);
47 }
48