xref: /llvm-project/clang/test/CXX/special/class.copy/p9.cpp (revision 909acf8209694495ba0dccd5d901c257729c5454)
1cfe68227SDouglas Gregor // RUN: %clang_cc1 -fsyntax-only -verify %s
2cfe68227SDouglas Gregor 
3cfe68227SDouglas Gregor struct ConstCopy {
4cfe68227SDouglas Gregor   ConstCopy();
5cfe68227SDouglas Gregor   ConstCopy(const ConstCopy&);
6cfe68227SDouglas Gregor };
7cfe68227SDouglas Gregor 
8cfe68227SDouglas Gregor struct NonConstCopy {
9cfe68227SDouglas Gregor   NonConstCopy();
10cfe68227SDouglas Gregor   NonConstCopy(NonConstCopy&);
11cfe68227SDouglas Gregor };
12cfe68227SDouglas Gregor 
13cfe68227SDouglas Gregor struct VirtualInheritsNonConstCopy : virtual NonConstCopy {
14cfe68227SDouglas Gregor   VirtualInheritsNonConstCopy();
15cfe68227SDouglas Gregor   VirtualInheritsNonConstCopy(const VirtualInheritsNonConstCopy&);
16cfe68227SDouglas Gregor };
17cfe68227SDouglas Gregor 
18*909acf82SJohn McCall struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note {{candidate constructor}}
19*909acf82SJohn McCall   ImplicitNonConstCopy1(); // expected-note {{candidate constructor}}
20cfe68227SDouglas Gregor };
21cfe68227SDouglas Gregor 
22*909acf82SJohn McCall struct ImplicitNonConstCopy2 { // expected-note {{candidate constructor}}
23*909acf82SJohn McCall   ImplicitNonConstCopy2(); // expected-note {{candidate constructor}}
24cfe68227SDouglas Gregor   NonConstCopy ncc;
25cfe68227SDouglas Gregor };
26cfe68227SDouglas Gregor 
27*909acf82SJohn McCall struct ImplicitNonConstCopy3 { // expected-note {{candidate constructor}}
28*909acf82SJohn McCall   ImplicitNonConstCopy3(); // expected-note {{candidate constructor}}
29cfe68227SDouglas Gregor   NonConstCopy ncc_array[2][3];
30cfe68227SDouglas Gregor };
31cfe68227SDouglas Gregor 
32*909acf82SJohn McCall struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { // expected-note {{candidate constructor}}
33*909acf82SJohn McCall   ImplicitNonConstCopy4(); // expected-note {{candidate constructor}}
34cfe68227SDouglas Gregor };
35cfe68227SDouglas Gregor 
test_non_const_copy(const ImplicitNonConstCopy1 & cincc1,const ImplicitNonConstCopy2 & cincc2,const ImplicitNonConstCopy3 & cincc3,const ImplicitNonConstCopy4 & cincc4)36cfe68227SDouglas Gregor void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,
37cfe68227SDouglas Gregor                          const ImplicitNonConstCopy2 &cincc2,
38cfe68227SDouglas Gregor                          const ImplicitNonConstCopy3 &cincc3,
39cfe68227SDouglas Gregor                          const ImplicitNonConstCopy4 &cincc4) {
40*909acf82SJohn McCall   (void)sizeof(ImplicitNonConstCopy1(cincc1)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy1' to 'ImplicitNonConstCopy1'}}
41*909acf82SJohn McCall   (void)sizeof(ImplicitNonConstCopy2(cincc2)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy2' to 'ImplicitNonConstCopy2'}}
42*909acf82SJohn McCall   (void)sizeof(ImplicitNonConstCopy3(cincc3)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy3' to 'ImplicitNonConstCopy3'}}
43*909acf82SJohn McCall   (void)sizeof(ImplicitNonConstCopy4(cincc4)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy4' to 'ImplicitNonConstCopy4'}}
44cfe68227SDouglas Gregor }
45