| 1 |
// RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
template<class T, class V> |
| 4 |
struct A{ |
| 5 |
A(); // expected-note{{candidate constructor not viable: requires 0 arguments, but 1 was provided}} |
| 6 |
A(A&); // expected-note{{candidate constructor not viable: expects an lvalue for 1st argument}} |
| 7 |
A(A<V, T>); // expected-error{{copy constructor must pass its first argument by reference}} |
| 8 |
}; |
| 9 |
|
| 10 |
void f() { |
| 11 |
A<int, int> a = A<int, int>(); // expected-note{{in instantiation of template class 'A<int, int>'}} |
| 12 |
A<int, double> a1 = A<double, int>(); // No error (not a copy constructor) |
| 13 |
} |
| 14 |
|
| 15 |
// Test rvalue-to-lvalue conversion in copy constructor |
| 16 |
A<int, int> &&a(void); |
| 17 |
void g() { |
| 18 |
A<int, int> a2 = a(); // expected-error{{no matching constructor}} |
| 19 |
} |
| 20 |
|
| 21 |
template<class T, class V> |
| 22 |
struct B{ |
| 23 |
B(); |
| 24 |
template<class U> B(U); // No error (templated constructor) |
| 25 |
}; |
| 26 |
|
| 27 |
void h() { |
| 28 |
B<int, int> b = B<int, int>(); // should use implicit copy constructor |
| 29 |
} |