Skip to content

Commit 12d9237

Browse files
committed
[Sema] Fix test diagnostics for copy-ctor-template
1 parent 4fe1d93 commit 12d9237

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

clang/test/SemaCXX/copy-ctor-template.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@
22

33
template<class T, class V>
44
struct A{
5-
A();
6-
A(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}}
77
A(A<V, T>); // expected-error{{copy constructor must pass its first argument by reference}}
88
};
99

1010
void f() {
11-
A<int, int> a = A<int, int>(); // expected-note{{in instantiation of template class 'A<int, int>'}}
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}}
1219
}
1320

1421
template<class T, class V>
@@ -17,6 +24,6 @@ struct B{
1724
template<class U> B(U); // No error (templated constructor)
1825
};
1926

20-
void g() {
27+
void h() {
2128
B<int, int> b = B<int, int>(); // should use implicit copy constructor
2229
}

0 commit comments

Comments
 (0)