Skip to content

Commit 790d151

Browse files
committed
[SemaCXX] Update constructor-template.cpp test for #80963
Adjust the test to account for new diagnostics emitted when a class template constructor takes the class by value after instantiation. - Add expected-error annotations to lines 142, 159, 172 (invalid by-value constructors when T = U). - Add expected-note annotations to lines 147, 164, 176 (template instantiation points). - Remove expected-error from line 76 (valid template specialization).
1 parent 12d9237 commit 790d151

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

clang/test/SemaTemplate/constructor-template.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct X3 {
7373
template<typename T> X3(T);
7474
};
7575

76-
template<> X3::X3(X3); // expected-error{{must pass its first argument by reference}}
76+
template<> X3::X3(X3); // No error (template constructor)
7777

7878
struct X4 {
7979
X4();
@@ -139,12 +139,12 @@ namespace self_by_value {
139139
template <class T, class U> struct A {
140140
A() {}
141141
A(const A<T,U> &o) {}
142-
A(A<T,T> o) {}
142+
A(A<T,T> o) {} // expected-error{{copy constructor must pass its first argument by reference}}
143143
};
144144

145145
void helper(A<int,float>);
146146

147-
void test1(A<int,int> a) {
147+
void test1(A<int,int> a) { // expected-note{{in instantiation of template class 'self_by_value::A<int, int>'}}
148148
helper(a);
149149
}
150150
void test2() {
@@ -156,24 +156,25 @@ namespace self_by_value_2 {
156156
template <class T, class U> struct A {
157157
A() {} // precxx17-note {{not viable: requires 0 arguments}}
158158
A(A<T,U> &o) {} // precxx17-note {{not viable: expects an lvalue}}
159-
A(A<T,T> o) {} // precxx17-note {{ignored: instantiation takes its own class type by value}}
159+
A(A<T,T> o) {} // expected-error{{copy constructor must pass its first argument by reference}}
160160
};
161161

162162
void helper_A(A<int,int>); // precxx17-note {{passing argument to parameter here}}
163163
void test_A() {
164-
helper_A(A<int,int>()); // precxx17-error {{no matching constructor}}
164+
helper_A(A<int,int>()); // precxx17-error {{no matching constructor}} \
165+
// expected-note{{in instantiation of template class 'self_by_value_2::A<int, int>'}}
165166
}
166167
}
167168

168169
namespace self_by_value_3 {
169170
template <class T, class U> struct A {
170171
A() {}
171172
A(A<T,U> &o) {}
172-
A(A<T,T> o) {}
173+
A(A<T,T> o) {} // expected-error{{copy constructor must pass its first argument by reference}}
173174
};
174175

175176
void helper_A(A<int,int>);
176-
void test_A(A<int,int> b) {
177+
void test_A(A<int,int> b) { // expected-note{{in instantiation of template class 'self_by_value_3::A<int, int>'}}
177178
helper_A(b);
178179
}
179180
}

0 commit comments

Comments
 (0)