xref: /minix3/external/bsd/llvm/dist/clang/test/SemaCXX/overload-call-copycon.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs
2*f4a2713aSLionel Sambuc class X { }; // expected-note {{the implicit copy constructor}} \
3*f4a2713aSLionel Sambuc              // expected-note{{the implicit default constructor}}
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc int& copycon(X x); // expected-note{{passing argument to parameter}}
6*f4a2713aSLionel Sambuc float& copycon(...);
7*f4a2713aSLionel Sambuc 
test_copycon(X x,X const xc,X volatile xv)8*f4a2713aSLionel Sambuc void test_copycon(X x, X const xc, X volatile xv) {
9*f4a2713aSLionel Sambuc   int& i1 = copycon(x);
10*f4a2713aSLionel Sambuc   int& i2 = copycon(xc);
11*f4a2713aSLionel Sambuc   copycon(xv); // expected-error{{no matching constructor}}
12*f4a2713aSLionel Sambuc }
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc class A {
15*f4a2713aSLionel Sambuc public:
16*f4a2713aSLionel Sambuc   A(A&); // expected-note{{would lose const qualifier}} \
17*f4a2713aSLionel Sambuc          // expected-note{{no known conversion}}
18*f4a2713aSLionel Sambuc };
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc class B : public A { }; // expected-note{{would lose const qualifier}} \
21*f4a2713aSLionel Sambuc // expected-note{{would lose volatile qualifier}} \
22*f4a2713aSLionel Sambuc // expected-note 2{{requires 0 arguments}}
23*f4a2713aSLionel Sambuc 
24*f4a2713aSLionel Sambuc short& copycon2(A a); // expected-note{{passing argument to parameter}}
25*f4a2713aSLionel Sambuc int& copycon2(B b); // expected-note 2{{passing argument to parameter}}
26*f4a2713aSLionel Sambuc float& copycon2(...);
27*f4a2713aSLionel Sambuc 
test_copycon2(A a,const A ac,B b,B const bc,B volatile bv)28*f4a2713aSLionel Sambuc void test_copycon2(A a, const A ac, B b, B const bc, B volatile bv) {
29*f4a2713aSLionel Sambuc   int& i1 = copycon2(b);
30*f4a2713aSLionel Sambuc   copycon2(bc); // expected-error{{no matching constructor}}
31*f4a2713aSLionel Sambuc   copycon2(bv); // expected-error{{no matching constructor}}
32*f4a2713aSLionel Sambuc   short& s1 = copycon2(a);
33*f4a2713aSLionel Sambuc   copycon2(ac); // expected-error{{no matching constructor}}
34*f4a2713aSLionel Sambuc }
35*f4a2713aSLionel Sambuc 
36*f4a2713aSLionel Sambuc int& copycon3(A a); // expected-note{{passing argument to parameter 'a' here}}
37*f4a2713aSLionel Sambuc float& copycon3(...);
38*f4a2713aSLionel Sambuc 
test_copycon3(B b,const B bc)39*f4a2713aSLionel Sambuc void test_copycon3(B b, const B bc) {
40*f4a2713aSLionel Sambuc   int& i1 = copycon3(b);
41*f4a2713aSLionel Sambuc   copycon3(bc); // expected-error{{no matching constructor}}
42*f4a2713aSLionel Sambuc }
43*f4a2713aSLionel Sambuc 
44*f4a2713aSLionel Sambuc class C : public B { };
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc float& copycon4(A a);
47*f4a2713aSLionel Sambuc int& copycon4(B b);
48*f4a2713aSLionel Sambuc 
test_copycon4(C c)49*f4a2713aSLionel Sambuc void test_copycon4(C c) {
50*f4a2713aSLionel Sambuc   int& i = copycon4(c);
51*f4a2713aSLionel Sambuc };
52