blob: 6720cb695338494cc0883b149e279cc70f1ecf15 [file] [log] [blame]
Douglas Gregorad323a82010-01-27 03:51:04 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s -Wnon-pod-varargs
Douglas Gregor604eb652010-08-11 02:15:33 +00002class X { }; // expected-note {{the implicit copy constructor}} \
3 // expected-note{{the implicit default constructor}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +00004
Douglas Gregor604eb652010-08-11 02:15:33 +00005int& copycon(X x); // expected-note{{passing argument to parameter}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +00006float& copycon(...);
7
8void test_copycon(X x, X const xc, X volatile xv) {
9 int& i1 = copycon(x);
10 int& i2 = copycon(xc);
Douglas Gregor604eb652010-08-11 02:15:33 +000011 copycon(xv); // expected-error{{no matching constructor}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000012}
13
14class A {
15public:
Douglas Gregor604eb652010-08-11 02:15:33 +000016 A(A&); // expected-note{{would lose const qualifier}} \
17 // expected-note{{no known conversion}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000018};
19
Douglas Gregor604eb652010-08-11 02:15:33 +000020class B : public A { }; // expected-note{{would lose const qualifier}} \
21// expected-note{{would lose volatile qualifier}} \
22// expected-note 2{{requires 0 arguments}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000023
Douglas Gregor604eb652010-08-11 02:15:33 +000024short& copycon2(A a); // expected-note{{passing argument to parameter}}
25int& copycon2(B b); // expected-note 2{{passing argument to parameter}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000026float& copycon2(...);
27
28void test_copycon2(A a, const A ac, B b, B const bc, B volatile bv) {
29 int& i1 = copycon2(b);
Douglas Gregor604eb652010-08-11 02:15:33 +000030 copycon2(bc); // expected-error{{no matching constructor}}
31 copycon2(bv); // expected-error{{no matching constructor}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000032 short& s1 = copycon2(a);
Douglas Gregor604eb652010-08-11 02:15:33 +000033 copycon2(ac); // expected-error{{no matching constructor}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000034}
35
Douglas Gregor604eb652010-08-11 02:15:33 +000036int& copycon3(A a); // expected-note{{passing argument to parameter 'a' here}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000037float& copycon3(...);
38
39void test_copycon3(B b, const B bc) {
40 int& i1 = copycon3(b);
Douglas Gregor604eb652010-08-11 02:15:33 +000041 copycon3(bc); // expected-error{{no matching constructor}}
Douglas Gregor396b7cd2008-11-03 17:51:48 +000042}
Douglas Gregor225c41e2008-11-03 19:09:14 +000043
Douglas Gregor225c41e2008-11-03 19:09:14 +000044class C : public B { };
45
46float& copycon4(A a);
47int& copycon4(B b);
48
49void test_copycon4(C c) {
50 int& i = copycon4(c);
51};