blob: cc1cc9ca70679ed8479bc813feadc7fc73e16433 [file] [log] [blame]
Rafael Espindola925213b2013-07-04 16:16:58 +00001// RUN: not %clang_cc1 -fsyntax-only %s -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-ELIDE-NOTREE
2// RUN: not %clang_cc1 -fsyntax-only %s -fno-elide-type -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-NOELIDE-NOTREE
3// RUN: not %clang_cc1 -fsyntax-only %s -fdiagnostics-show-template-tree -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-ELIDE-TREE
4// RUN: not %clang_cc1 -fsyntax-only %s -fno-elide-type -fdiagnostics-show-template-tree -std=c++11 2>&1 | FileCheck %s -check-prefix=CHECK-NOELIDE-TREE
Richard Trieu91844232012-06-26 18:18:47 +00005
6// PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'"
7// vector<string> refers to two different types here. Make sure the message
8// gives a way to tell them apart.
9class versa_string;
10typedef versa_string string;
11
12namespace std {template <typename T> class vector;}
13using std::vector;
14
15void f(vector<string> v);
16
17namespace std {
18 class basic_string;
19 typedef basic_string string;
20 template <typename T> class vector {};
21 void g() {
22 vector<string> v;
23 f(v);
24 }
25} // end namespace std
26// CHECK-ELIDE-NOTREE: no matching function for call to 'f'
Alex Lorenz76377dc2017-03-10 15:04:58 +000027// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<std::string>' to 'vector<string>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000028// CHECK-NOELIDE-NOTREE: no matching function for call to 'f'
Alex Lorenz76377dc2017-03-10 15:04:58 +000029// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<std::string>' to 'vector<string>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000030// CHECK-ELIDE-TREE: no matching function for call to 'f'
Richard Trieudb96a422012-06-29 23:11:10 +000031// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000032// CHECK-ELIDE-TREE: vector<
Alex Lorenz76377dc2017-03-10 15:04:58 +000033// CHECK-ELIDE-TREE: [std::string != string]>
Richard Trieu91844232012-06-26 18:18:47 +000034// CHECK-NOELIDE-TREE: no matching function for call to 'f'
Richard Trieudb96a422012-06-29 23:11:10 +000035// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000036// CHECK-NOELIDE-TREE: vector<
Alex Lorenz76377dc2017-03-10 15:04:58 +000037// CHECK-NOELIDE-TREE: [std::string != string]>
Richard Trieu91844232012-06-26 18:18:47 +000038
39template <int... A>
40class I1{};
41void set1(I1<1,2,3,4,2,3,4,3>) {};
42void test1() {
43 set1(I1<1,2,3,4,2,2,4,3,7>());
44}
45// CHECK-ELIDE-NOTREE: no matching function for call to 'set1'
46// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I1<[5 * ...], 2, [2 * ...], 7>' to 'I1<[5 * ...], 3, [2 * ...], (no argument)>' for 1st argument
47// CHECK-NOELIDE-NOTREE: no matching function for call to 'set1'
48// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I1<1, 2, 3, 4, 2, 2, 4, 3, 7>' to 'I1<1, 2, 3, 4, 2, 3, 4, 3, (no argument)>' for 1st argument
49// CHECK-ELIDE-TREE: no matching function for call to 'set1'
Richard Trieudb96a422012-06-29 23:11:10 +000050// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000051// CHECK-ELIDE-TREE: I1<
52// CHECK-ELIDE-TREE: [5 * ...],
53// CHECK-ELIDE-TREE: [2 != 3],
54// CHECK-ELIDE-TREE: [2 * ...],
55// CHECK-ELIDE-TREE: [7 != (no argument)]>
56// CHECK-NOELIDE-TREE: no matching function for call to 'set1'
Richard Trieudb96a422012-06-29 23:11:10 +000057// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000058// CHECK-NOELIDE-TREE: I1<
59// CHECK-NOELIDE-TREE: 1,
60// CHECK-NOELIDE-TREE: 2,
61// CHECK-NOELIDE-TREE: 3,
62// CHECK-NOELIDE-TREE: 4,
63// CHECK-NOELIDE-TREE: 2,
64// CHECK-NOELIDE-TREE: [2 != 3],
65// CHECK-NOELIDE-TREE: 4,
66// CHECK-NOELIDE-TREE: 3,
67// CHECK-NOELIDE-TREE: [7 != (no argument)]>
68
69template <class A, class B, class C = void>
70class I2{};
71void set2(I2<int, int>) {};
72void test2() {
73 set2(I2<double, int, int>());
74}
75// CHECK-ELIDE-NOTREE: no matching function for call to 'set2'
76// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I2<double, [...], int>' to 'I2<int, [...], (default) void>' for 1st argument
77// CHECK-NOELIDE-NOTREE: no matching function for call to 'set2'
78// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I2<double, int, int>' to 'I2<int, int, (default) void>' for 1st argument
79// CHECK-ELIDE-TREE: no matching function for call to 'set2'
Richard Trieudb96a422012-06-29 23:11:10 +000080// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000081// CHECK-ELIDE-TREE: I2<
82// CHECK-ELIDE-TREE: [double != int],
83// CHECK-ELIDE-TREE: [...],
84// CHECK-ELIDE-TREE: [int != (default) void]>
85// CHECK-NOELIDE-TREE: no matching function for call to 'set2'
Richard Trieudb96a422012-06-29 23:11:10 +000086// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +000087// CHECK-NOELIDE-TREE: I2<
88// CHECK-NOELIDE-TREE: [double != int],
89// CHECK-NOELIDE-TREE: int,
90// CHECK-NOELIDE-TREE: [int != (default) void]>
91
92int V1, V2, V3;
93template <int* A, int *B>
94class I3{};
95void set3(I3<&V1, &V2>) {};
96void test3() {
97 set3(I3<&V3, &V2>());
98}
99// CHECK-ELIDE-NOTREE: no matching function for call to 'set3'
100// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, [...]>' to 'I3<&V1, [...]>' for 1st argument
101// CHECK-NOELIDE-NOTREE: no matching function for call to 'set3'
102// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, &V2>' to 'I3<&V1, &V2>' for 1st argument
103// CHECK-ELIDE-TREE: no matching function for call to 'set3'
Richard Trieudb96a422012-06-29 23:11:10 +0000104// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000105// CHECK-ELIDE-TREE: I3<
106// CHECK-ELIDE-TREE: [&V3 != &V1]
107// CHECK-ELIDE-TREE: [...]>
108// CHECK-NOELIDE-TREE: no matching function for call to 'set3'
Richard Trieudb96a422012-06-29 23:11:10 +0000109// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000110// CHECK-NOELIDE-TREE: I3<
111// CHECK-NOELIDE-TREE: [&V3 != &V1]
112// CHECK-NOELIDE-TREE: &V2>
113
114template <class A, class B>
115class Alpha{};
116template <class A, class B>
117class Beta{};
118template <class A, class B>
119class Gamma{};
120template <class A, class B>
121class Delta{};
122
123void set4(Alpha<int, int>);
124void test4() {
125 set4(Beta<void, void>());
126}
127// CHECK-ELIDE-NOTREE: no matching function for call to 'set4'
128// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
129// CHECK-NOELIDE-NOTREE: no matching function for call to 'set4'
130// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
131// CHECK-ELIDE-TREE: no matching function for call to 'set4'
132// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
133// CHECK-NOELIDE-TREE: no matching function for call to 'set4'
134// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
135
136void set5(Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>);
137void test5() {
138 set5(Alpha<Beta<Gamma<void, void>, double>, double>());
139}
140// CHECK-ELIDE-NOTREE: no matching function for call to 'set5'
141// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Gamma<void, void>, double>, double>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>' for 1st argument
142// CHECK-NOELIDE-NOTREE: no matching function for call to 'set5'
143// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Gamma<void, void>, double>, double>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>' for 1st argument
144// CHECK-ELIDE-TREE: no matching function for call to 'set5'
Richard Trieudb96a422012-06-29 23:11:10 +0000145// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000146// CHECK-ELIDE-TREE: Alpha<
147// CHECK-ELIDE-TREE: Beta<
148// CHECK-ELIDE-TREE: Gamma<
149// CHECK-ELIDE-TREE: [void != Delta<int, int>],
150// CHECK-ELIDE-TREE: [void != int]>
151// CHECK-ELIDE-TREE: [double != int]>
152// CHECK-ELIDE-TREE: [double != int]>
153// CHECK-NOELIDE-TREE: no matching function for call to 'set5'
Richard Trieudb96a422012-06-29 23:11:10 +0000154// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000155// CHECK-NOELIDE-TREE: Alpha<
156// CHECK-NOELIDE-TREE: Beta<
157// CHECK-NOELIDE-TREE: Gamma<
158// CHECK-NOELIDE-TREE: [void != Delta<int, int>],
159// CHECK-NOELIDE-TREE: [void != int]>
160// CHECK-NOELIDE-TREE: [double != int]>
161// CHECK-NOELIDE-TREE: [double != int]>
162
163void test6() {
164 set5(Alpha<Beta<Delta<int, int>, int>, int>());
165}
166// CHECK-ELIDE-NOTREE: no matching function for call to 'set5'
167// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Delta<int, int>, [...]>, [...]>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, [...]>, [...]>' for 1st argument
168// CHECK-NOELIDE-NOTREE: no matching function for call to 'set5'
169// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Alpha<Beta<Delta<int, int>, int>, int>' to 'Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>' for 1st argument
170// CHECK-ELIDE-TREE: no matching function for call to 'set5'
Richard Trieudb96a422012-06-29 23:11:10 +0000171// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000172// CHECK-ELIDE-TREE: Alpha<
173// CHECK-ELIDE-TREE: Beta<
174// CHECK-ELIDE-TREE: [Delta<int, int> != Gamma<Delta<int, int>, int>],
175// CHECK-ELIDE-TREE: [...]>
176// CHECK-ELIDE-TREE: [...]>
177// CHECK-NOELIDE-TREE: no matching function for call to 'set5'
Richard Trieudb96a422012-06-29 23:11:10 +0000178// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000179// CHECK-NOELIDE-TREE: Alpha<
180// CHECK-NOELIDE-TREE: Beta<
181// CHECK-NOELIDE-TREE: [Delta<int, int> != Gamma<Delta<int, int>, int>],
182// CHECK-NOELIDE-TREE: int>
183// CHECK-NOELIDE-TREE: int>
184
185int a7, b7;
186int c7[] = {1,2,3};
187template<int *A>
188class class7 {};
189void set7(class7<&a7> A) {}
190void test7() {
191 set7(class7<&a7>());
192 set7(class7<&b7>());
193 set7(class7<c7>());
194 set7(class7<nullptr>());
195}
196// CHECK-ELIDE-NOTREE: no matching function for call to 'set7'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000197// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000198// CHECK-ELIDE-NOTREE: no matching function for call to 'set7'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000199// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<c7>' to 'class7<&a7>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000200// CHECK-ELIDE-NOTREE: no matching function for call to 'set7'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000201// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<nullptr>' to 'class7<&a7>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000202// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000203// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000204// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000205// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<c7>' to 'class7<&a7>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000206// CHECK-NOELIDE-NOTREE: no matching function for call to 'set7'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000207// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<nullptr>' to 'class7<&a7>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000208// CHECK-ELIDE-TREE: no matching function for call to 'set7'
Richard Trieudb96a422012-06-29 23:11:10 +0000209// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000210// CHECK-ELIDE-TREE: class7<
211// CHECK-ELIDE-TREE: [&b7 != &a7]>
212// CHECK-ELIDE-TREE: no matching function for call to 'set7'
Richard Trieudb96a422012-06-29 23:11:10 +0000213// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000214// CHECK-ELIDE-TREE: class7<
215// CHECK-ELIDE-TREE: [c7 != &a7]>
216// CHECK-ELIDE-TREE: no matching function for call to 'set7'
Richard Trieudb96a422012-06-29 23:11:10 +0000217// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000218// CHECK-ELIDE-TREE: class7<
219// CHECK-ELIDE-TREE: [nullptr != &a7]>
220// CHECK-NOELIDE-TREE: no matching function for call to 'set7'
Richard Trieudb96a422012-06-29 23:11:10 +0000221// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000222// CHECK-NOELIDE-TREE: class7<
223// CHECK-NOELIDE-TREE: [&b7 != &a7]>
224// CHECK-NOELIDE-TREE: no matching function for call to 'set7'
Richard Trieudb96a422012-06-29 23:11:10 +0000225// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000226// CHECK-NOELIDE-TREE: class7<
227// CHECK-NOELIDE-TREE: [c7 != &a7]>
228// CHECK-NOELIDE-TREE: no matching function for call to 'set7'
Richard Trieudb96a422012-06-29 23:11:10 +0000229// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000230// CHECK-NOELIDE-TREE: class7<
231// CHECK-NOELIDE-TREE: [nullptr != &a7]>
232
233template<typename ...T> struct S8 {};
234template<typename T> using U8 = S8<int, char, T>;
235int f8(S8<int, char, double>);
236int k8 = f8(U8<char>());
237// CHECK-ELIDE-NOTREE: no matching function for call to 'f8'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000238// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<[2 * ...], char>' to 'S8<[2 * ...], double>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000239// CHECK-NOELIDE-NOTREE: no matching function for call to 'f8'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000240// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<int, char, char>' to 'S8<int, char, double>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000241// CHECK-ELIDE-TREE: no matching function for call to 'f8'
Richard Trieudb96a422012-06-29 23:11:10 +0000242// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000243// CHECK-ELIDE-TREE: S8<
244// CHECK-ELIDE-TREE: [2 * ...],
245// CHECK-ELIDE-TREE: [char != double]>
246// CHECK-NOELIDE-TREE: no matching function for call to 'f8'
Richard Trieudb96a422012-06-29 23:11:10 +0000247// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000248// CHECK-NOELIDE-TREE: S8<
249// CHECK-NOELIDE-TREE: int,
250// CHECK-NOELIDE-TREE: char,
251// CHECK-NOELIDE-TREE: [char != double]>
252
253template<typename ...T> struct S9 {};
254template<typename T> using U9 = S9<int, char, T>;
255template<typename T> using V9 = U9<U9<T>>;
256int f9(S9<int, char, U9<const double>>);
257int k9 = f9(V9<double>());
258
259// CHECK-ELIDE-NOTREE: no matching function for call to 'f9'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000260// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<[2 * ...], S9<[2 * ...], double>>' to 'S9<[2 * ...], S9<[2 * ...], const double>>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000261// CHECK-NOELIDE-NOTREE: no matching function for call to 'f9'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000262// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<int, char, S9<int, char, double>>' to 'S9<int, char, S9<int, char, const double>>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000263// CHECK-ELIDE-TREE: no matching function for call to 'f9'
Richard Trieudb96a422012-06-29 23:11:10 +0000264// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000265// CHECK-ELIDE-TREE: S9<
266// CHECK-ELIDE-TREE: [2 * ...],
267// CHECK-ELIDE-TREE: S9<
268// CHECK-ELIDE-TREE: [2 * ...],
269// CHECK-ELIDE-TREE: [double != const double]>>
270// CHECK-NOELIDE-TREE: no matching function for call to 'f9'
Richard Trieudb96a422012-06-29 23:11:10 +0000271// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000272// CHECK-NOELIDE-TREE: S9<
273// CHECK-NOELIDE-TREE: int,
274// CHECK-NOELIDE-TREE: char,
275// CHECK-NOELIDE-TREE: S9<
276// CHECK-NOELIDE-TREE: int,
277// CHECK-NOELIDE-TREE: char,
278// CHECK-NOELIDE-TREE: [double != const double]>>
279
280template<typename ...A> class class_types {};
281void set10(class_types<int, int>) {}
282void test10() {
283 set10(class_types<int>());
284 set10(class_types<int, int, int>());
285}
286
287// CHECK-ELIDE-NOTREE: no matching function for call to 'set10'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000288// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[...], (no argument)>' to 'class_types<[...], int>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000289// CHECK-ELIDE-NOTREE: no matching function for call to 'set10'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000290// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[2 * ...], int>' to 'class_types<[2 * ...], (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000291// CHECK-NOELIDE-NOTREE: no matching function for call to 'set10'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000292// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<int, (no argument)>' to 'class_types<int, int>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000293// CHECK-NOELIDE-NOTREE: no matching function for call to 'set10'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000294// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<int, int, int>' to 'class_types<int, int, (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000295// CHECK-ELIDE-TREE: no matching function for call to 'set10'
Richard Trieudb96a422012-06-29 23:11:10 +0000296// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000297// CHECK-ELIDE-TREE: class_types<
298// CHECK-ELIDE-TREE: [...],
299// CHECK-ELIDE-TREE: [(no argument) != int]>
300// CHECK-ELIDE-TREE: no matching function for call to 'set10'
Richard Trieudb96a422012-06-29 23:11:10 +0000301// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000302// CHECK-ELIDE-TREE: class_types<
303// CHECK-ELIDE-TREE: [2 * ...],
304// CHECK-ELIDE-TREE: [int != (no argument)]>
305// CHECK-NOELIDE-TREE: no matching function for call to 'set10'
Richard Trieudb96a422012-06-29 23:11:10 +0000306// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000307// CHECK-NOELIDE-TREE: class_types<
308// CHECK-NOELIDE-TREE: int,
309// CHECK-NOELIDE-TREE: [(no argument) != int]>
310// CHECK-NOELIDE-TREE: no matching function for call to 'set10'
Richard Trieudb96a422012-06-29 23:11:10 +0000311// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000312// CHECK-NOELIDE-TREE: class_types<
313// CHECK-NOELIDE-TREE: int,
314// CHECK-NOELIDE-TREE: int,
315// CHECK-NOELIDE-TREE: [int != (no argument)]>
316
317template<int ...A> class class_ints {};
318void set11(class_ints<2, 3>) {}
319void test11() {
320 set11(class_ints<1>());
321 set11(class_ints<0, 3, 6>());
322}
323// CHECK-ELIDE-NOTREE: no matching function for call to 'set11'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000324// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000325// CHECK-ELIDE-NOTREE: no matching function for call to 'set11'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000326// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, [...], 6>' to 'class_ints<2, [...], (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000327// CHECK-NOELIDE-NOTREE: no matching function for call to 'set11'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000328// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000329// CHECK-NOELIDE-NOTREE: no matching function for call to 'set11'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000330// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, 3, 6>' to 'class_ints<2, 3, (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000331// CHECK-ELIDE-TREE: no matching function for call to 'set11'
Richard Trieudb96a422012-06-29 23:11:10 +0000332// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000333// CHECK-ELIDE-TREE: class_ints<
334// CHECK-ELIDE-TREE: [1 != 2],
335// CHECK-ELIDE-TREE: [(no argument) != 3]>
336// CHECK-ELIDE-TREE: no matching function for call to 'set11'
Richard Trieudb96a422012-06-29 23:11:10 +0000337// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000338// CHECK-ELIDE-TREE: class_ints<
339// CHECK-ELIDE-TREE: [0 != 2],
340// CHECK-ELIDE-TREE: [...],
341// CHECK-ELIDE-TREE: [6 != (no argument)]>
342// CHECK-NOELIDE-TREE: no matching function for call to 'set11'
Richard Trieudb96a422012-06-29 23:11:10 +0000343// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000344// CHECK-NOELIDE-TREE: class_ints<
345// CHECK-NOELIDE-TREE: [1 != 2],
346// CHECK-NOELIDE-TREE: [(no argument) != 3]>
347// CHECK-NOELIDE-TREE: no matching function for call to 'set11'
Richard Trieudb96a422012-06-29 23:11:10 +0000348// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000349// CHECK-NOELIDE-TREE: class_ints<
350// CHECK-NOELIDE-TREE: [0 != 2],
351// CHECK-NOELIDE-TREE: 3,
352// CHECK-NOELIDE-TREE: [6 != (no argument)]>
353
354template<template<class> class ...A> class class_template_templates {};
355template<class> class tt1 {};
356template<class> class tt2 {};
357void set12(class_template_templates<tt1, tt1>) {}
358void test12() {
359 set12(class_template_templates<tt2>());
360 set12(class_template_templates<tt1, tt1, tt1>());
361}
362// CHECK-ELIDE-NOTREE: no matching function for call to 'set12'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000363// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<template tt2, template (no argument)>' to 'class_template_templates<template tt1, template tt1>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000364// CHECK-ELIDE-NOTREE: no matching function for call to 'set12'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000365// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<[2 * ...], template tt1>' to 'class_template_templates<[2 * ...], template (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000366// CHECK-NOELIDE-NOTREE: no matching function for call to 'set12'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000367// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<template tt2, template (no argument)>' to 'class_template_templates<template tt1, template tt1>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000368// CHECK-NOELIDE-NOTREE: no matching function for call to 'set12'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000369// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_template_templates<template tt1, template tt1, template tt1>' to 'class_template_templates<template tt1, template tt1, template (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000370// CHECK-ELIDE-TREE: no matching function for call to 'set12'
Richard Trieudb96a422012-06-29 23:11:10 +0000371// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000372// CHECK-ELIDE-TREE: class_template_templates<
373// CHECK-ELIDE-TREE: [template tt2 != template tt1],
374// CHECK-ELIDE-TREE: [template (no argument) != template tt1]>
375// CHECK-ELIDE-TREE: no matching function for call to 'set12'
Richard Trieudb96a422012-06-29 23:11:10 +0000376// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000377// CHECK-ELIDE-TREE: class_template_templates<
378// CHECK-ELIDE-TREE: [2 * ...],
379// CHECK-ELIDE-TREE: [template tt1 != template (no argument)]>
380// CHECK-NOELIDE-TREE: no matching function for call to 'set12'
Richard Trieudb96a422012-06-29 23:11:10 +0000381// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000382// CHECK-NOELIDE-TREE: class_template_templates<
383// CHECK-NOELIDE-TREE: [template tt2 != template tt1],
384// CHECK-NOELIDE-TREE: [template (no argument) != template tt1]>
385// CHECK-NOELIDE-TREE: no matching function for call to 'set12'
Richard Trieudb96a422012-06-29 23:11:10 +0000386// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000387// CHECK-NOELIDE-TREE: class_template_templates<
388// CHECK-NOELIDE-TREE: template tt1,
389// CHECK-NOELIDE-TREE: template tt1,
390// CHECK-NOELIDE-TREE: [template tt1 != template (no argument)]>
391
392double a13, b13, c13, d13;
393template<double* ...A> class class_ptrs {};
394void set13(class_ptrs<&a13, &b13>) {}
395void test13() {
396 set13(class_ptrs<&c13>());
Richard Smithb23c5e82019-05-09 03:31:27 +0000397 set13(class_ptrs<&a13, &b13, &d13>());
Richard Trieu91844232012-06-26 18:18:47 +0000398}
399// CHECK-ELIDE-NOTREE: no matching function for call to 'set13'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000400// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&c13, (no argument)>' to 'class_ptrs<&a13, &b13>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000401// CHECK-ELIDE-NOTREE: no matching function for call to 'set13'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000402// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<[2 * ...], &d13>' to 'class_ptrs<[2 * ...], (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000403// CHECK-NOELIDE-NOTREE: no matching function for call to 'set13'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000404// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&c13, (no argument)>' to 'class_ptrs<&a13, &b13>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000405// CHECK-NOELIDE-NOTREE: no matching function for call to 'set13'
Matt Beaumont-Gay15716522012-06-28 19:20:41 +0000406// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&a13, &b13, &d13>' to 'class_ptrs<&a13, &b13, (no argument)>' for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000407// CHECK-ELIDE-TREE: no matching function for call to 'set13'
Richard Trieudb96a422012-06-29 23:11:10 +0000408// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000409// CHECK-ELIDE-TREE: class_ptrs<
410// CHECK-ELIDE-TREE: [&c13 != &a13],
411// CHECK-ELIDE-TREE: [(no argument) != &b13]>
412// CHECK-ELIDE-TREE: no matching function for call to 'set13'
Richard Trieudb96a422012-06-29 23:11:10 +0000413// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000414// CHECK-ELIDE-TREE: class_ptrs<
415// CHECK-ELIDE-TREE: [2 * ...],
416// CHECK-ELIDE-TREE: [&d13 != (no argument)]>
417// CHECK-NOELIDE-TREE: no matching function for call to 'set13'
Richard Trieudb96a422012-06-29 23:11:10 +0000418// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000419// CHECK-NOELIDE-TREE: class_ptrs<
420// CHECK-NOELIDE-TREE: [&c13 != &a13],
421// CHECK-NOELIDE-TREE: [(no argument) != &b13]>
422// CHECK-NOELIDE-TREE: no matching function for call to 'set13'
Richard Trieudb96a422012-06-29 23:11:10 +0000423// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu91844232012-06-26 18:18:47 +0000424// CHECK-NOELIDE-TREE: class_ptrs<
425// CHECK-NOELIDE-TREE: &a13,
426// CHECK-NOELIDE-TREE: &b13,
427// CHECK-NOELIDE-TREE: [&d13 != (no argument)]>
428
Richard Smith6e0605d2012-09-26 02:18:13 +0000429template<typename T> struct s14 {};
430template<typename T> using a14 = s14<T>;
431typedef a14<int> b14;
432template<typename T> using c14 = b14;
433int f14(c14<int>);
434int k14 = f14(a14<char>());
435// CHECK-ELIDE-NOTREE: no matching function for call to 'f14'
436// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'a14<char>' to 'a14<int>' for 1st argument
437// CHECK-NOELIDE-NOTREE: no matching function for call to 'f14'
438// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'a14<char>' to 'a14<int>' for 1st argument
439// CHECK-ELIDE-TREE: no matching function for call to 'f14'
440// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
441// CHECK-ELIDE-TREE: a14<
442// CHECK-ELIDE-TREE: [char != int]>
443// CHECK-NOELIDE-TREE: no matching function for call to 'f14'
444// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
445// CHECK-NOELIDE-TREE: a14<
446// CHECK-NOELIDE-TREE: [char != int]>
Richard Trieu91844232012-06-26 18:18:47 +0000447
Richard Trieub7243852012-09-28 20:32:51 +0000448void set15(vector<vector<int>>) {}
449void test15() {
450 set15(vector<vector<int>>());
451}
452// CHECK-ELIDE-NOTREE-NOT: set15
453// CHECK-NOELIDE-NOTREE-NOT: set15
454// CHECK-ELIDE-TREE-NOT: set15
455// CHECK-NOELIDE-TREE-NOT: set15
456// no error here
457
458void set16(vector<const vector<int>>) {}
459void test16() {
460 set16(vector<const vector<const int>>());
461}
462// CHECK-ELIDE-NOTREE: no matching function for call to 'set16'
463// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<const int>>' to 'vector<const vector<int>>' for 1st argument
464// CHECK-NOELIDE-NOTREE: no matching function for call to 'set16'
465// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<const int>>' to 'vector<const vector<int>>' for 1st argument
466// CHECK-ELIDE-TREE: no matching function for call to 'set16'
467// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
468// CHECK-ELIDE-TREE: vector<
469// CHECK-ELIDE-TREE: const vector<
470// CHECK-ELIDE-TREE: [const != (no qualifiers)] int>>
471// CHECK-NOELIDE-TREE: no matching function for call to 'set16'
472// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
473// CHECK-NOELIDE-TREE: vector<
474// CHECK-NOELIDE-TREE: const vector<
475// CHECK-NOELIDE-TREE: [const != (no qualifiers)] int>>
476
477void set17(vector<vector<int>>) {}
478void test17() {
479 set17(vector<const vector<int>>());
480}
481// CHECK-ELIDE-NOTREE: no matching function for call to 'set17'
Richard Trieu12074502016-02-02 00:36:59 +0000482// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<...>>' to 'vector<vector<...>>' for 1st argument
Richard Trieub7243852012-09-28 20:32:51 +0000483// CHECK-NOELIDE-NOTREE: no matching function for call to 'set17'
484// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<int>>' to 'vector<vector<int>>' for 1st argument
485// CHECK-ELIDE-TREE: no matching function for call to 'set17'
486// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
487// CHECK-ELIDE-TREE: vector<
Richard Trieu12074502016-02-02 00:36:59 +0000488// CHECK-ELIDE-TREE: [const != (no qualifiers)] vector<...>>
Richard Trieub7243852012-09-28 20:32:51 +0000489// CHECK-NOELIDE-TREE: no matching function for call to 'set17'
490// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
491// CHECK-NOELIDE-TREE: vector<
492// CHECK-NOELIDE-TREE: [const != (no qualifiers)] vector<
493// CHECK-NOELIDE-TREE: int>>
494
495void set18(vector<const vector<int>>) {}
496void test18() {
497 set18(vector<vector<int>>());
498}
499// CHECK-ELIDE-NOTREE: no matching function for call to 'set18'
Richard Trieu12074502016-02-02 00:36:59 +0000500// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<vector<...>>' to 'vector<const vector<...>>' for 1st argument
Richard Trieub7243852012-09-28 20:32:51 +0000501// CHECK-NOELIDE-NOTREE: no matching function for call to 'set18'
502// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<vector<int>>' to 'vector<const vector<int>>' for 1st argument
503// CHECK-ELIDE-TREE: no matching function for call to 'set18'
504// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
505// CHECK-ELIDE-TREE: vector<
Richard Trieu12074502016-02-02 00:36:59 +0000506// CHECK-ELIDE-TREE: [(no qualifiers) != const] vector<...>>
Richard Trieub7243852012-09-28 20:32:51 +0000507// CHECK-NOELIDE-TREE: no matching function for call to 'set18'
508// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
509// CHECK-NOELIDE-TREE: vector<
510// CHECK-NOELIDE-TREE: [(no qualifiers) != const] vector<
511// CHECK-NOELIDE-TREE: int>>
512
513void set19(vector<volatile vector<int>>) {}
514void test19() {
515 set19(vector<const vector<int>>());
516}
517// CHECK-ELIDE-NOTREE: no matching function for call to 'set19'
Richard Trieu12074502016-02-02 00:36:59 +0000518// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<...>>' to 'vector<volatile vector<...>>' for 1st argument
Richard Trieub7243852012-09-28 20:32:51 +0000519// CHECK-NOELIDE-NOTREE: no matching function for call to 'set19'
520// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<int>>' to 'vector<volatile vector<int>>' for 1st argument
521// CHECK-ELIDE-TREE: no matching function for call to 'set19'
522// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
523// CHECK-ELIDE-TREE: vector<
Richard Trieu12074502016-02-02 00:36:59 +0000524// CHECK-ELIDE-TREE: [const != volatile] vector<...>>
Richard Trieub7243852012-09-28 20:32:51 +0000525// CHECK-NOELIDE-TREE: no matching function for call to 'set19'
526// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
527// CHECK-NOELIDE-TREE: vector<
528// CHECK-NOELIDE-TREE: [const != volatile] vector<
529// CHECK-NOELIDE-TREE: int>>
530
531void set20(vector<const volatile vector<int>>) {}
532void test20() {
533 set20(vector<const vector<int>>());
534}
535// CHECK-ELIDE-NOTREE: no matching function for call to 'set20'
Richard Trieu12074502016-02-02 00:36:59 +0000536// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<...>>' to 'vector<const volatile vector<...>>' for 1st argument
Richard Trieub7243852012-09-28 20:32:51 +0000537// CHECK-NOELIDE-NOTREE: no matching function for call to 'set20'
538// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<int>>' to 'vector<const volatile vector<int>>' for 1st argument
539// CHECK-ELIDE-TREE: no matching function for call to 'set20'
540// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
541// CHECK-ELIDE-TREE: vector<
Richard Trieu12074502016-02-02 00:36:59 +0000542// CHECK-ELIDE-TREE: [const != const volatile] vector<...>>
Richard Trieub7243852012-09-28 20:32:51 +0000543// CHECK-NOELIDE-TREE: no matching function for call to 'set20'
544// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
545// CHECK-NOELIDE-TREE: vector<
546// CHECK-NOELIDE-TREE: [const != const volatile] vector<
547// CHECK-NOELIDE-TREE: int>>
548
549
550// Checks that volatile does not show up in diagnostics.
551template<typename T> struct S21 {};
552template<typename T> using U21 = volatile S21<T>;
553int f21(vector<const U21<int>>);
554int k21 = f21(vector<U21<int>>());
555// CHECK-ELIDE-NOTREE: no matching function for call to 'f21'
Richard Trieu12074502016-02-02 00:36:59 +0000556// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U21<...>>' to 'vector<const U21<...>>' for 1st argument
Richard Trieub7243852012-09-28 20:32:51 +0000557// CHECK-NOELIDE-NOTREE: no matching function for call to 'f21'
558// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U21<int>>' to 'vector<const U21<int>>' for 1st argument
559// CHECK-ELIDE-TREE: no matching function for call to 'f21'
560// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
561// CHECK-ELIDE-TREE: vector<
Richard Trieu12074502016-02-02 00:36:59 +0000562// CHECK-ELIDE-TREE: [(no qualifiers) != const] U21<...>>
Richard Trieub7243852012-09-28 20:32:51 +0000563// CHECK-NOELIDE-TREE: no matching function for call to 'f21'
564// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
565// CHECK-NOELIDE-TREE: vector<
566// CHECK-NOELIDE-TREE: [(no qualifiers) != const] U21<
567// CHECK-NOELIDE-TREE: int>>
568
569// Checks that volatile does not show up in diagnostics.
570template<typename T> struct S22 {};
571template<typename T> using U22 = volatile S22<T>;
572int f22(vector<volatile const U22<int>>);
573int k22 = f22(vector<volatile U22<int>>());
574// CHECK-ELIDE-NOTREE: no matching function for call to 'f22'
Richard Trieu12074502016-02-02 00:36:59 +0000575// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U22<...>>' to 'vector<const U22<...>>' for 1st argument
Richard Trieub7243852012-09-28 20:32:51 +0000576// CHECK-NOELIDE-NOTREE: no matching function for call to 'f22'
577// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U22<int>>' to 'vector<const U22<int>>' for 1st argument
578// CHECK-ELIDE-TREE: no matching function for call to 'f22'
579// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
580// CHECK-ELIDE-TREE: vector<
Richard Trieu12074502016-02-02 00:36:59 +0000581// CHECK-ELIDE-TREE: [(no qualifiers) != const] U22<...>>
Richard Trieub7243852012-09-28 20:32:51 +0000582// CHECK-NOELIDE-TREE: no matching function for call to 'f22'
583// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
584// CHECK-NOELIDE-TREE: vector<
585// CHECK-NOELIDE-TREE: [(no qualifiers) != const] U22<
586// CHECK-NOELIDE-TREE: int>>
587
588// Testing qualifiers and typedefs.
589template <class T> struct D23{};
590template <class T> using C23 = D23<T>;
591typedef const C23<int> B23;
592template<class ...T> using A23 = B23;
593
594void foo23(D23<A23<>> b) {}
595void test23() {
596 foo23(D23<D23<char>>());
597 foo23(C23<char>());
598}
599
600// CHECK-ELIDE-NOTREE: no matching function for call to 'foo23'
601// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<D23<char>>' to 'D23<const D23<int>>' for 1st argument
602// CHECK-ELIDE-NOTREE: no matching function for call to 'foo23'
603// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<char>' to 'D23<A23<>>' for 1st argument
604// CHECK-NOELIDE-NOTREE: no matching function for call to 'foo23'
605// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<D23<char>>' to 'D23<const D23<int>>' for 1st argument
606// CHECK-NOELIDE-NOTREE: no matching function for call to 'foo23'
607// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<char>' to 'D23<A23<>>' for 1st argument
608// CHECK-ELIDE-TREE: no matching function for call to 'foo23'
609// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
610// CHECK-ELIDE-TREE: D23<
611// CHECK-ELIDE-TREE: [(no qualifiers) != const] D23<
612// CHECK-ELIDE-TREE: [char != int]>>
613// CHECK-ELIDE-TREE: no matching function for call to 'foo23'
614// CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
615// CHECK-ELIDE-TREE: D23<
616// CHECK-ELIDE-TREE: [char != A23<>]>
617// CHECK-NOELIDE-TREE: no matching function for call to 'foo23'
618// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
619// CHECK-NOELIDE-TREE: D23<
620// CHECK-NOELIDE-TREE: [(no qualifiers) != const] D23<
621// CHECK-NOELIDE-TREE: [char != int]>>
622// CHECK-NOELIDE-TREE: no matching function for call to 'foo23'
623// CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
624// CHECK-NOELIDE-TREE: D23<
625// CHECK-NOELIDE-TREE: [char != A23<>]>
626
Richard Trieu6df89452012-11-01 21:29:28 +0000627namespace PR14015 {
628template <unsigned N> class Foo1 {};
629template <unsigned N = 2> class Foo2 {};
630template <unsigned ...N> class Foo3 {};
631
632void Play1() {
633 Foo1<1> F1;
634 Foo1<2> F2, F3;
635 F2 = F1;
636 F1 = F2;
637 F2 = F3;
638 F3 = F2;
639}
640
641// CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000642// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000643// CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
644// CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000645// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000646// CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
647// CHECK-NOELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000648// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<1>' to 'const Foo1<2>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000649// CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
650// CHECK-NOELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000651// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo1<2>' to 'const Foo1<1>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000652// CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
653// CHECK-ELIDE-TREE: no viable overloaded '='
654// CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000655// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1<
Richard Trieu6df89452012-11-01 21:29:28 +0000656// CHECK-ELIDE-TREE: [1 != 2]>
657// CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
658// CHECK-ELIDE-TREE: Foo1<
659// CHECK-ELIDE-TREE: [1 != 2]>
660// CHECK-ELIDE-TREE: no viable overloaded '='
661// CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000662// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1<
Richard Trieu6df89452012-11-01 21:29:28 +0000663// CHECK-ELIDE-TREE: [2 != 1]>
664// CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
665// CHECK-ELIDE-TREE: Foo1<
666// CHECK-ELIDE-TREE: [2 != 1]>
667// CHECK-NOELIDE-TREE: no viable overloaded '='
668// CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000669// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1<
Richard Trieu6df89452012-11-01 21:29:28 +0000670// CHECK-NOELIDE-TREE: [1 != 2]>
671// CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
672// CHECK-NOELIDE-TREE: Foo1<
673// CHECK-NOELIDE-TREE: [1 != 2]>
674// CHECK-NOELIDE-TREE: no viable overloaded '='
675// CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000676// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1<
Richard Trieu6df89452012-11-01 21:29:28 +0000677// CHECK-NOELIDE-TREE: [2 != 1]>
678// CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
679// CHECK-NOELIDE-TREE: Foo1<
680// CHECK-NOELIDE-TREE: [2 != 1]>
681
682void Play2() {
683 Foo2<1> F1;
684 Foo2<> F2, F3;
685 F2 = F1;
686 F1 = F2;
687 F2 = F3;
688 F3 = F2;
689}
690// CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000691// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000692// CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
693// CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000694// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000695// CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument
696// CHECK-NOELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000697// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<1>' to 'const Foo2<2>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000698// CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
699// CHECK-NOELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000700// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'const Foo2<1>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000701// CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<(default) 2>' to 'Foo2<1>' for 1st argument
702// CHECK-ELIDE-TREE: no viable overloaded '='
703// CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000704// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2<
Richard Trieu6df89452012-11-01 21:29:28 +0000705// CHECK-ELIDE-TREE: [1 != 2]>
706// CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
707// CHECK-ELIDE-TREE: Foo2<
708// CHECK-ELIDE-TREE: [1 != 2]>
709// CHECK-ELIDE-TREE: no viable overloaded '='
710// CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000711// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2<
Richard Trieu6df89452012-11-01 21:29:28 +0000712// CHECK-ELIDE-TREE: [(default) 2 != 1]>
713// CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
714// CHECK-ELIDE-TREE: Foo2<
715// CHECK-ELIDE-TREE: [(default) 2 != 1]>
716// CHECK-NOELIDE-TREE: no viable overloaded '='
717// CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000718// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2<
Richard Trieu6df89452012-11-01 21:29:28 +0000719// CHECK-NOELIDE-TREE: [1 != 2]>
720// CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
721// CHECK-NOELIDE-TREE: Foo2<
722// CHECK-NOELIDE-TREE: [1 != 2]>
723// CHECK-NOELIDE-TREE: no viable overloaded '='
724// CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000725// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2<
Richard Trieu6df89452012-11-01 21:29:28 +0000726// CHECK-NOELIDE-TREE: [(default) 2 != 1]>
727// CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
728// CHECK-NOELIDE-TREE: Foo2<
729// CHECK-NOELIDE-TREE: [(default) 2 != 1]>
730
731void Play3() {
732 Foo3<1> F1;
733 Foo3<2, 1> F2, F3;
734 F2 = F1;
735 F1 = F2;
736 F2 = F3;
737 F3 = F2;
738}
739// CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000740// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000741// CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument
742// CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000743// CHECK-ELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000744// CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument
745// CHECK-NOELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000746// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'const Foo3<2, 1>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000747// CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<1, (no argument)>' to 'Foo3<2, 1>' for 1st argument
748// CHECK-NOELIDE-NOTREE: no viable overloaded '='
Richard Trieu3cee4132013-03-23 01:38:36 +0000749// CHECK-NOELIDE-NOTREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'const Foo3<1, (no argument)>' for 1st argument
Richard Trieu6df89452012-11-01 21:29:28 +0000750// CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo3<2, 1>' to 'Foo3<1, (no argument)>' for 1st argument
751// CHECK-ELIDE-TREE: no viable overloaded '='
752// CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000753// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3<
Richard Trieu6df89452012-11-01 21:29:28 +0000754// CHECK-ELIDE-TREE: [1 != 2],
755// CHECK-ELIDE-TREE: [(no argument) != 1]>
756// CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
757// CHECK-ELIDE-TREE: Foo3<
758// CHECK-ELIDE-TREE: [1 != 2],
759// CHECK-ELIDE-TREE: [(no argument) != 1]>
760// CHECK-ELIDE-TREE: no viable overloaded '='
761// CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000762// CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3<
Richard Trieu6df89452012-11-01 21:29:28 +0000763// CHECK-ELIDE-TREE: [2 != 1],
764// CHECK-ELIDE-TREE: [1 != (no argument)]>
765// CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
766// CHECK-ELIDE-TREE: Foo3<
767// CHECK-ELIDE-TREE: [2 != 1],
768// CHECK-ELIDE-TREE: [1 != (no argument)]>
769// CHECK-NOELIDE-TREE: no viable overloaded '='
770// CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000771// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3<
Richard Trieu6df89452012-11-01 21:29:28 +0000772// CHECK-NOELIDE-TREE: [1 != 2],
773// CHECK-NOELIDE-TREE: [(no argument) != 1]>
774// CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
775// CHECK-NOELIDE-TREE: Foo3<
776// CHECK-NOELIDE-TREE: [1 != 2],
777// CHECK-NOELIDE-TREE: [(no argument) != 1]>
778// CHECK-NOELIDE-TREE: no viable overloaded '='
779// CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
Richard Trieu3cee4132013-03-23 01:38:36 +0000780// CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3<
Richard Trieu6df89452012-11-01 21:29:28 +0000781// CHECK-NOELIDE-TREE: [2 != 1],
782// CHECK-NOELIDE-TREE: [1 != (no argument)]>
783// CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
784// CHECK-NOELIDE-TREE: Foo3<
785// CHECK-NOELIDE-TREE: [2 != 1],
786// CHECK-NOELIDE-TREE: [1 != (no argument)]>
787}
788
Eli Friedmanc2c982c2012-11-14 23:57:08 +0000789namespace PR14342 {
790 template<typename T, short a> struct X {};
791 X<int, (signed char)-1> x = X<long, -1>();
792 X<int, 3UL> y = X<int, 2>();
793 // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>'
Richard Trieu64ab30392013-03-15 23:55:09 +0000794 // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<[...], 2>' to 'X<[...], 3>'
Eli Friedmanc2c982c2012-11-14 23:57:08 +0000795}
Richard Trieu6df89452012-11-01 21:29:28 +0000796
Eli Friedman40ea2642012-12-18 23:32:47 +0000797namespace PR14489 {
798 // The important thing here is that the diagnostic diffs a template specialization
799 // with no arguments against itself. (We might need a different test if this
800 // diagnostic changes).
801 template<class ...V>
802 struct VariableList {
803 void ConnectAllToAll(VariableList<>& params = VariableList<>()) {
804 }
805 };
806 // CHECK-ELIDE-NOTREE: non-const lvalue reference to type 'VariableList<>' cannot bind to a temporary of type 'VariableList<>'
807}
808
Douglas Gregor2d5a5612012-12-21 23:03:27 +0000809namespace rdar12456626 {
810 struct IntWrapper {
811 typedef int type;
812 };
813
814 template<typename T, typename T::type V>
815 struct X { };
816
817 struct A {
818 virtual X<IntWrapper, 1> foo();
819 };
820
821 struct B : A {
822 // CHECK-ELIDE-NOTREE: virtual function 'foo' has a different return type
823 virtual X<IntWrapper, 2> foo();
824 };
825}
826
Richard Trieu90c31f52013-01-30 20:04:31 +0000827namespace PR15023 {
828 // Don't crash when non-QualTypes are passed to a diff modifier.
829 template <typename... Args>
830 void func(void (*func)(Args...), Args...) { }
831
832 void bar(int, int &) {
833 }
834
835 void foo(int x) {
836 func(bar, 1, x)
837 }
838 // CHECK-ELIDE-NOTREE: no matching function for call to 'func'
839 // CHECK-ELIDE-NOTREE: candidate template ignored: deduced conflicting types for parameter 'Args' (<int, int &> vs. <int, int>)
840}
841
Douglas Gregor8e9f55f2013-01-31 01:08:35 +0000842namespace rdar12931988 {
843 namespace A {
844 template<typename T> struct X { };
845 }
846
847 namespace B {
848 template<typename T> struct X { };
849 }
850
851 void foo(A::X<int> &ax, B::X<int> bx) {
852 // CHECK-ELIDE-NOTREE: no viable overloaded '='
853 // CHECK-ELIDE-NOTREE: no known conversion from 'B::X<int>' to 'const rdar12931988::A::X<int>'
854 ax = bx;
855 }
Richard Trieue673d71a2013-01-31 02:47:46 +0000856
857 template<template<typename> class> class Y {};
858
859 void bar(Y<A::X> ya, Y<B::X> yb) {
860 // CHECK-ELIDE-NOTREE: no viable overloaded '='
861 // CHECK-ELIDE-NOTREE: no known conversion from 'Y<template rdar12931988::B::X>' to 'Y<template rdar12931988::A::X>'
862 ya = yb;
863 }
Douglas Gregor8e9f55f2013-01-31 01:08:35 +0000864}
865
Richard Trieu954aaaf2013-02-27 01:41:53 +0000866namespace ValueDecl {
867 int int1, int2, default_int;
868 template <const int& T = default_int>
869 struct S {};
870
871 typedef S<int1> T1;
872 typedef S<int2> T2;
873 typedef S<> TD;
874
875 void test() {
876 T1 t1;
877 T2 t2;
878 TD td;
879
880 t1 = t2;
881 // CHECK-ELIDE-NOTREE: no viable overloaded '='
882 // CHECK-ELIDE-NOTREE: no known conversion from 'S<int2>' to 'S<int1>'
883
884 t2 = t1;
885 // CHECK-ELIDE-NOTREE: no viable overloaded '='
886 // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<int2>'
887
888 td = t1;
889 // TODO: Find out why (default) isn't printed on second template.
890 // CHECK-ELIDE-NOTREE: no viable overloaded '='
891 // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<default_int>'
892
893 t2 = td;
894 // CHECK-ELIDE-NOTREE: no viable overloaded '='
895 // CHECK-ELIDE-NOTREE: no known conversion from 'S<(default) default_int>' to 'S<int2>'
896
897 }
898}
899
Richard Trieu981de5c2013-04-03 02:11:36 +0000900namespace DependentDefault {
901 template <typename> struct Trait {
902 enum { V = 40 };
903 typedef int Ty;
904 static int I;
905 };
906 int other;
907
908 template <typename T, int = Trait<T>::V > struct A {};
909 template <typename T, typename = Trait<T>::Ty > struct B {};
910 template <typename T, int& = Trait<T>::I > struct C {};
911
912 void test() {
913
914 A<int> a1;
915 A<char> a2;
916 A<int, 10> a3;
917 a1 = a2;
918 // CHECK-ELIDE-NOTREE: no viable overloaded '='
919 // CHECK-ELIDE-NOTREE: no known conversion from 'A<char, [...]>' to 'A<int, [...]>'
920 a3 = a1;
921 // CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu14714c42016-01-14 22:56:39 +0000922 // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (default) Trait<T>::V aka 40>' to 'A<[...], 10>'
Richard Trieu981de5c2013-04-03 02:11:36 +0000923 a2 = a3;
924 // CHECK-ELIDE-NOTREE: no viable overloaded '='
925 // CHECK-ELIDE-NOTREE: no known conversion from 'A<int, 10>' to 'A<char, 40>'
926
927 B<int> b1;
928 B<char> b2;
929 B<int, char> b3;
930 b1 = b2;
931 // CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu8ed6f2a2013-07-20 03:49:02 +0000932 // CHECK-ELIDE-NOTREE: no known conversion from 'B<char, [...]>' to 'B<int, [...]>'
Richard Trieu981de5c2013-04-03 02:11:36 +0000933 b3 = b1;
934 // CHECK-ELIDE-NOTREE: no viable overloaded '='
Richard Trieu8ed6f2a2013-07-20 03:49:02 +0000935 // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) int>' to 'B<[...], char>'
Richard Trieu981de5c2013-04-03 02:11:36 +0000936 b2 = b3;
937 // CHECK-ELIDE-NOTREE: no viable overloaded '='
938 // CHECK-ELIDE-NOTREE: no known conversion from 'B<int, char>' to 'B<char, int>'
939
940 C<int> c1;
941 C<char> c2;
942 C<int, other> c3;
943 c1 = c2;
944 // CHECK-ELIDE-NOTREE: no viable overloaded '='
945 // CHECK-ELIDE-NOTREE: no known conversion from 'C<char, (default) I>' to 'C<int, I>'
946 c3 = c1;
947 // CHECK-ELIDE-NOTREE: no viable overloaded '='
948 // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (default) I>' to 'C<[...], other>'
949 c2 = c3;
950 // CHECK-ELIDE-NOTREE: no viable overloaded '='
951 // CHECK-ELIDE-NOTREE: no known conversion from 'C<int, other>' to 'C<char, I>'
952 }
953}
954
Richard Trieuad13f552013-04-03 02:22:12 +0000955namespace VariadicDefault {
956 int i1, i2, i3;
957 template <int = 5, int...> struct A {};
958 template <int& = i1, int& ...> struct B {};
959 template <typename = void, typename...> struct C {};
960
961 void test() {
962 A<> a1;
963 A<5, 6, 7> a2;
964 A<1, 2> a3;
965 a2 = a1;
966 // CHECK-ELIDE-NOTREE: no viable overloaded '='
967 // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (no argument), (no argument)>' to 'A<[...], 6, 7>'
968 a3 = a1;
969 // CHECK-ELIDE-NOTREE: no viable overloaded '='
970 // CHECK-ELIDE-NOTREE: no known conversion from 'A<(default) 5, (no argument)>' to 'A<1, 2>'
971
972 B<> b1;
973 B<i1, i2, i3> b2;
974 B<i2, i3> b3;
975 b2 = b1;
976 // CHECK-ELIDE-NOTREE: no viable overloaded '='
977 // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>'
978 b3 = b1;
979 // CHECK-ELIDE-NOTREE: no viable overloaded '='
980 // CHECK-ELIDE-NOTREE: no known conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>'
981
Richard Trieubcd06c02013-04-03 02:31:17 +0000982 B<i1, i2, i3> b4 = b1;
983 // CHECK-ELIDE-NOTREE: no viable conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>'
984 B<i2, i3> b5 = b1;
985 // CHECK-ELIDE-NOTREE: no viable conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>'
986
Richard Trieuad13f552013-04-03 02:22:12 +0000987 C<> c1;
988 C<void, void> c2;
989 C<char, char> c3;
990 c2 = c1;
991 // CHECK-ELIDE-NOTREE: no viable overloaded '='
992 // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (no argument)>' to 'C<[...], void>'
993 c3 = c1;
994 // CHECK-ELIDE-NOTREE: no viable overloaded '='
995 // CHECK-ELIDE-NOTREE: no known conversion from 'C<(default) void, (no argument)>' to 'C<char, char>'
996 }
997}
998
Richard Trieu091872c52013-05-07 21:36:24 +0000999namespace PointerArguments {
1000 template <int *p> class T {};
1001 template <int* ...> class U {};
1002 int a, b, c;
1003 int z[5];
1004 void test() {
1005 T<&a> ta;
1006 T<z> tz;
1007 T<&b> tb(ta);
1008 // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'T<&b>'
1009 // CHECK-ELIDE-NOTREE: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'T<&a>' to 'const T<&b>' for 1st argument
1010 T<&c> tc(tz);
1011 // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'T<&c>'
1012 // CHECK-ELIDE-NOTREE: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'T<z>' to 'const T<&c>' for 1st argument
1013
1014 U<&a, &a> uaa;
1015 U<&b> ub(uaa);
1016 // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'U<&b>'
1017 // CHECK-ELIDE-NOTREE: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'U<&a, &a>' to 'const U<&b, (no argument)>' for 1st argument
1018
1019 U<&b, &b, &b> ubbb(uaa);
1020 // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'U<&b, &b, &b>'
1021 // CHECK-ELIDE-NOTREE: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'U<&a, &a, (no argument)>' to 'const U<&b, &b, &b>' for 1st argument
1022
1023 }
1024}
1025
Richard Trieu8ed6f2a2013-07-20 03:49:02 +00001026namespace DependentInt {
1027 template<int Num> struct INT;
1028
1029 template <class CLASS, class Int_wrapper = INT<CLASS::val> >
1030 struct C;
1031
1032 struct N {
1033 static const int val = 1;
1034 };
1035
1036 template <class M_T>
1037 struct M {};
1038
1039 void test() {
1040 using T1 = M<C<int, INT<0>>>;
1041 using T2 = M<C<N>>;
1042 T2 p;
1043 T1 x = p;
Richard Trieud86c9012014-07-25 00:24:02 +00001044 // CHECK-ELIDE-NOTREE: no viable conversion from 'M<C<DependentInt::N, INT<1>>>' to 'M<C<int, INT<0>>>'
Richard Trieu8ed6f2a2013-07-20 03:49:02 +00001045 }
1046}
1047
Benjamin Kramer3b05e202013-10-08 16:58:52 +00001048namespace PR17510 {
1049class Atom;
1050
1051template <typename T> class allocator;
1052template <typename T, typename A> class vector;
1053
1054typedef vector<const Atom *, allocator<const Atom *> > AtomVector;
1055
1056template <typename T, typename A = allocator<const Atom *> > class vector {};
1057
1058void foo() {
1059 vector<Atom *> v;
1060 AtomVector v2(v);
Richard Trieud86c9012014-07-25 00:24:02 +00001061 // CHECK-ELIDE-NOTREE: no known conversion from 'vector<PR17510::Atom *, [...]>' to 'const vector<const PR17510::Atom *, [...]>'
Benjamin Kramer3b05e202013-10-08 16:58:52 +00001062}
1063}
1064
Nikola Smiljanic3fe1e092014-07-01 04:17:53 +00001065namespace PR15677 {
1066template <bool>
1067struct A{};
1068
1069template <typename T>
1070using B = A<T::value>;
1071
1072template <typename T>
1073using B = A<!T::value>;
1074// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<!T::value>' vs 'A<T::value>')
1075
1076template <int>
1077struct C{};
1078
1079template <typename T>
1080using D = C<T::value>;
1081
1082template <typename T>
1083using D = C<T::value + 1>;
1084// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('C<T::value + 1>' vs 'C<T::value>')
1085
1086template <typename T>
1087using E = C<T::value>;
1088
1089template <typename T>
1090using E = C<42>;
1091// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('C<42>' vs 'C<T::value>')
1092
1093template <typename T>
1094using F = C<T::value>;
1095
1096template <typename T>
1097using F = C<21 + 21>;
1098// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('C<21 + 21 aka 42>' vs 'C<T::value>')
1099}
1100}
1101
Richard Trieu965cfa12014-07-22 03:33:01 +00001102namespace AddressOf {
1103template <int*>
1104struct S {};
1105
1106template <class T>
1107struct Wrapper {};
1108
1109template <class T>
1110Wrapper<T> MakeWrapper();
Richard Trieu63056c32014-07-22 04:06:54 +00001111int global, global2;
Richard Trieu965cfa12014-07-22 03:33:01 +00001112constexpr int * ptr = nullptr;
1113Wrapper<S<ptr>> W = MakeWrapper<S<&global>>();
1114// Don't print an extra '&' for 'ptr'
Richard Trieu2c22a862016-01-15 01:08:56 +00001115// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr aka nullptr>>'
Richard Trieu63056c32014-07-22 04:06:54 +00001116
Richard Trieu63056c32014-07-22 04:06:54 +00001117// Handle parens correctly
Richard Trieud53def22014-07-22 04:42:15 +00001118Wrapper<S<(&global2)>> W2 = MakeWrapper<S<&global>>();
1119// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
1120Wrapper<S<&global2>> W3 = MakeWrapper<S<(&global)>>();
1121// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
1122Wrapper<S<(&global2)>> W4 = MakeWrapper<S<(&global)>>();
1123// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
Richard Trieu965cfa12014-07-22 03:33:01 +00001124}
1125
Richard Trieu38800892014-07-24 04:24:50 +00001126namespace NullPtr {
1127template <int*, int*>
1128struct S {};
1129
1130template <class T>
1131struct Wrapper {};
1132
1133template <class T>
1134Wrapper<T> MakeWrapper();
1135int global, global2;
1136constexpr int * ptr = nullptr;
1137constexpr int * ptr2 = static_cast<int*>(0);
1138
1139S<&global> s1 = S<&global, ptr>();
1140S<&global, nullptr> s2 = S<&global, ptr>();
1141
1142S<&global, nullptr> s3 = S<&global, &global>();
1143// CHECK-ELIDE-NOTREE: no viable conversion from 'S<[...], &global>' to 'S<[...], nullptr>'
1144S<&global, ptr> s4 = S<&global, &global>();
Richard Trieu2c22a862016-01-15 01:08:56 +00001145// CHECK-ELIDE-NOTREE: no viable conversion from 'S<[...], &global>' to 'S<[...], ptr aka nullptr>
Richard Trieu38800892014-07-24 04:24:50 +00001146
1147Wrapper<S<&global, nullptr>> W1 = MakeWrapper<S<&global, ptr>>();
1148Wrapper<S<&global, static_cast<int*>(0)>> W2 = MakeWrapper<S<&global, ptr>>();
1149
1150Wrapper<S<&global, nullptr>> W3 = MakeWrapper<S<&global, &global>>();
1151// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], nullptr>>'
1152Wrapper<S<&global, ptr>> W4 = MakeWrapper<S<&global, &global>>();
Richard Trieu2c22a862016-01-15 01:08:56 +00001153// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], ptr aka nullptr>>'
Richard Trieu38800892014-07-24 04:24:50 +00001154
1155Wrapper<S<&global2, ptr>> W5 = MakeWrapper<S<&global, nullptr>>();
1156// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1157Wrapper<S<&global2, nullptr>> W6 = MakeWrapper<S<&global, nullptr>>();
1158// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1159Wrapper<S<&global2, ptr2>> W7 = MakeWrapper<S<&global, nullptr>>();
1160// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1161Wrapper<S<&global2, nullptr>> W8 = MakeWrapper<S<&global, ptr2>>();
1162// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1163Wrapper<S<&global2, ptr>> W9 = MakeWrapper<S<&global, ptr2>>();
1164// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1165Wrapper<S<&global2, ptr2>> W10 = MakeWrapper<S<&global, ptr>>();
1166// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1167Wrapper<S<&global2, static_cast<int *>(0)>> W11 =
1168 MakeWrapper<S<&global, nullptr>>();
1169// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1170Wrapper<S<&global2, nullptr>> W12 =
1171 MakeWrapper<S<&global, static_cast<int *>(0)>>();
1172// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
1173
1174Wrapper<S<&global, &global>> W13 = MakeWrapper<S<&global, ptr>>();
Richard Trieu11608312014-07-24 23:14:16 +00001175// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], nullptr>>' to 'Wrapper<S<[...], &global>>'
Richard Trieu38800892014-07-24 04:24:50 +00001176Wrapper<S<&global, ptr>> W14 = MakeWrapper<S<&global, &global>>();
Richard Trieu2c22a862016-01-15 01:08:56 +00001177// CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], ptr aka nullptr>>'
Richard Trieu38800892014-07-24 04:24:50 +00001178}
1179
Richard Trieu11608312014-07-24 23:14:16 +00001180namespace TemplateTemplateDefault {
1181template <class> class A{};
1182template <class> class B{};
1183template <class> class C{};
1184template <template <class> class, template <class> class = A>
1185 class T {};
1186
1187T<A> t1 = T<A, C>();
1188// CHECK-ELIDE-NOTREE: no viable conversion from 'T<[...], template C>' to 'T<[...], (default) template A>'
1189T<A, C> t2 = T<A>();
1190// CHECK-ELIDE-NOTREE: no viable conversion from 'T<[...], (default) template A>' to 'T<[...], template C>'
1191T<A> t3 = T<B>();
1192// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template B>' to 'T<template A>'
1193T<B, C> t4 = T<C, B>();
1194// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template C, template B>' to 'T<template B, template C>'
1195T<A, A> t5 = T<B>();
1196// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template B, [...]>' to 'T<template A, [...]>'
1197T<B> t6 = T<A, A>();
1198// CHECK-ELIDE-NOTREE: no viable conversion from 'T<template A, [...]>' to 'T<template B, [...]>'
1199}
1200
Richard Trieud86c9012014-07-25 00:24:02 +00001201namespace Bool {
1202template <class> class A{};
1203A<bool> a1 = A<int>();
1204// CHECK-ELIDE-NOTREE: no viable conversion from 'A<int>' to 'A<bool>'
1205A<int> a2 = A<bool>();
1206// CHECK-ELIDE-NOTREE: no viable conversion from 'A<bool>' to 'A<int>'
1207}
1208
Richard Trieu97bacec2014-07-26 02:10:52 +00001209namespace TypeAlias {
1210template <int, int = 0> class A {};
1211
1212template <class T> using a = A<T::num, 0>;
1213template <class T> using a = A<T::num>;
1214
1215template <class T> using A1 = A<T::num>;
1216template <class T> using A1 = A<T::num + 0>;
1217// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 0>' vs 'A<T::num>')
1218
1219template <class T> using A2 = A<1 + T::num>;
1220template <class T> using A2 = A<T::num + 1>;
1221// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 1>' vs 'A<1 + T::num>')
1222
1223template <class T> using A3 = A<(T::num)>;
1224template <class T> using A3 = A<T::num>;
1225// CHECK-ELIDE-NOTREE: error: type alias template redefinition with different types ('A<T::num>' vs 'A<(T::num)>')
1226
1227 template <class T> using A4 = A<(T::num)>;
1228template <class T> using A4 = A<((T::num))>;
1229// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<((T::num))>' vs 'A<(T::num)>')
1230
1231template <class T> using A5 = A<T::num, 1>;
1232template <class T> using A5 = A<T::num>;
1233// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
1234
1235template <class T> using A6 = A<T::num + 5, 1>;
1236template <class T> using A6 = A<T::num + 5>;
1237// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
1238
1239template <class T> using A7 = A<T::num, 1>;
1240template <class T> using A7 = A<(T::num)>;
1241// CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<(T::num), (default) 0>' vs 'A<T::num, 1>')
1242}
1243
Richard Trieu15b66532015-01-24 02:48:32 +00001244namespace TemplateArgumentImplicitConversion {
1245template <int X> struct condition {};
1246
1247struct is_const {
1248 constexpr operator int() const { return 10; }
1249};
1250
1251using T = condition<(is_const())>;
1252void foo(const T &t) {
1253 T &t2 = t;
1254}
Anastasia Stulova1da9e4c2019-06-21 10:50:02 +00001255// CHECK-ELIDE-NOTREE: binding reference of type 'condition<...>' to value of type 'const condition<...>' drops 'const' qualifier
Richard Trieu15b66532015-01-24 02:48:32 +00001256}
1257
Richard Trieu555c9672015-02-26 02:40:48 +00001258namespace BoolArgumentBitExtended {
1259template <bool B> struct BoolT {};
1260
1261template <typename T> void foo(T) {}
1262
1263void test() {
1264 BoolT<false> X;
1265 foo<BoolT<true>>(X);
1266}
1267// CHECK-ELIDE-NOTREE: no matching function for call to 'foo'
Eric Fiselier4977c372018-05-30 01:22:14 +00001268// CHECK-ELIDE-NOTREE: candidate function template not viable: no known conversion from 'BoolT<false>' to 'BoolT<true>' for 1st argument
Richard Trieu555c9672015-02-26 02:40:48 +00001269}
1270
Richard Trieud5c73782016-01-15 02:55:17 +00001271namespace DifferentIntegralTypes {
1272template<typename T, T n>
1273class A{};
1274void foo() {
1275 A<int, 1> a1 = A<long long, 1>();
1276 A<unsigned int, 1> a2 = A<int, 5>();
1277 A<bool, true> a3 = A<signed char, true>();
1278}
1279// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<long long, (long long) 1>' to 'A<int, (int) 1>'
1280// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int, (int) 5>' to 'A<unsigned int, (unsigned int) 1>'
1281// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<signed char, (signed char) 1>' to 'A<bool, (bool) true>'
1282}
1283
Richard Trieu9213ce52016-01-15 05:01:53 +00001284namespace MixedDeclarationIntegerArgument {
1285template<typename T, T n> class A{};
1286int x;
1287int y[5];
1288
1289A<int, 5> a1 = A<int&, x>();
1290A<int, 5 - 1> a2 = A<int*, &x>();
1291A<int, 5 + 1> a3 = A<int*, y>();
1292A<int, 0> a4 = A<int**, nullptr>();
1293// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int &, x>' to 'A<int, 5>'
1294// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int *, &x>' to 'A<int, 5 - 1 aka 4>'
1295// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int *, y>' to 'A<int, 5 + 1 aka 6>'
1296// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int **, nullptr>' to 'A<int, 0>'
1297// CHECK-ELIDE-TREE: error: no viable conversion
1298// CHECK-ELIDE-TREE: A<
1299// CHECK-ELIDE-TREE: [int & != int],
1300// CHECK-ELIDE-TREE: [x != 5]>
1301// CHECK-ELIDE-TREE: error: no viable conversion
1302// CHECK-ELIDE-TREE: A<
1303// CHECK-ELIDE-TREE: [int * != int],
1304// CHECK-ELIDE-TREE: [&x != 5 - 1 aka 4]>
1305// CHECK-ELIDE-TREE: error: no viable conversion
1306// CHECK-ELIDE-TREE: A<
1307// CHECK-ELIDE-TREE: [int * != int],
1308// CHECK-ELIDE-TREE: [y != 5 + 1 aka 6]>
1309// CHECK-ELIDE-TREE: error: no viable conversion
1310// CHECK-ELIDE-TREE: A<
1311// CHECK-ELIDE-TREE: [int ** != int],
1312// CHECK-ELIDE-TREE: [nullptr != 0]>
1313
1314A<int&, x> a5 = A<int, 3>();
1315A<int*, &x> a6 = A<int, 3 - 1>();
1316A<int*, y> a7 = A<int, 3 + 1>();
1317A<int**, nullptr> a8 = A<int, 3>();
1318// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int, 3>' to 'A<int &, x>'
1319// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int, 3 - 1 aka 2>' to 'A<int *, &x>'
1320// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int, 3 + 1 aka 4>' to 'A<int *, y>'
1321// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<int, 3>' to 'A<int **, nullptr>'
1322// CHECK-ELIDE-TREE: error: no viable conversion
1323// CHECK-ELIDE-TREE: A<
1324// CHECK-ELIDE-TREE: [int != int &],
1325// CHECK-ELIDE-TREE: [3 != x]>
1326// CHECK-ELIDE-TREE: error: no viable conversion
1327// CHECK-ELIDE-TREE: A<
1328// CHECK-ELIDE-TREE: [int != int *],
1329// CHECK-ELIDE-TREE: [3 - 1 aka 2 != &x]>
1330// CHECK-ELIDE-TREE: error: no viable conversion
1331// CHECK-ELIDE-TREE: A<
1332// CHECK-ELIDE-TREE: [int != int *],
1333// CHECK-ELIDE-TREE: [3 + 1 aka 4 != y]>
1334// CHECK-ELIDE-TREE: error: no viable conversion
1335// CHECK-ELIDE-TREE: A<
1336// CHECK-ELIDE-TREE: [int != int **],
1337// CHECK-ELIDE-TREE: [3 != nullptr]>
1338
1339template<class T, T n = x> class B{} ;
1340B<int, 5> b1 = B<int&>();
1341// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<int &, (default) x>' to 'B<int, 5>'
1342// CHECK-ELIDE-TREE: error: no viable conversion
1343// CHECK-ELIDE-TREE: B<
1344// CHECK-ELIDE-TREE: [int & != int],
1345// CHECK-ELIDE-TREE: [(default) x != 5]>
1346
1347B<int &> b2 = B<int, 2>();
1348// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<int, 2>' to 'B<int &, (default) x>'
1349// CHECK-ELIDE-TREE: B<
1350// CHECK-ELIDE-TREE: [int != int &],
1351// CHECK-ELIDE-TREE: [2 != (default) x]>
1352
1353template<class T, T n = 11> class C {};
1354C<int> c1 = C<int&, x>();
1355// CHECK-ELIDE-NOTREE: error: no viable conversion from 'C<int &, x>' to 'C<int, (default) 11>'
1356// CHECK-ELIDE-TREE: error: no viable conversion
1357// CHECK-ELIDE-TREE: C<
1358// CHECK-ELIDE-TREE: [int & != int],
1359// CHECK-ELIDE-TREE: [x != (default) 11]>
1360
1361C<int &, x> c2 = C<int>();
1362// CHECK-ELIDE-NOTREE: error: no viable conversion from 'C<int, (default) 11>' to 'C<int &, x>'
1363// CHECK-ELIDE-TREE: C<
1364// CHECK-ELIDE-TREE: [int != int &],
1365// CHECK-ELIDE-TREE: [(default) 11 != x]>
1366}
Richard Trieud5c73782016-01-15 02:55:17 +00001367
Richard Trieu2331c8b2016-01-15 05:48:38 +00001368namespace default_args {
1369 template <int x, int y = 1+1, int z = 2>
1370 class A {};
1371
1372 void foo(A<0> &M) {
1373 // CHECK-ELIDE-NOTREE: no viable conversion from 'A<[...], (default) 1 + 1 aka 2, (default) 2>' to 'A<[...], 0, 0>'
1374 A<0, 0, 0> N = M;
1375
1376 // CHECK-ELIDE-NOTREE: no viable conversion from 'A<[2 * ...], (default) 2>' to 'A<[2 * ...], 0>'
1377 A<0, 2, 0> N2 = M;
1378 }
1379}
1380
1381namespace DefaultNonTypeArgWithDependentType {
1382// We used to crash diffing integer template arguments when the argument type
1383// is dependent and default arguments were used.
1384template <typename SizeType = int, SizeType = 0> struct A {};
1385template <typename R = A<>> R bar();
1386A<> &foo() { return bar(); }
Richard Trieu12074502016-02-02 00:36:59 +00001387// CHECK-ELIDE-NOTREE: error: non-const lvalue reference to type 'A<...>' cannot bind to a temporary of type 'A<...>'
Richard Trieu2331c8b2016-01-15 05:48:38 +00001388// CHECK-NOELIDE-NOTREE: error: non-const lvalue reference to type 'A<int, 0>' cannot bind to a temporary of type 'A<int, 0>'
1389}
1390
1391namespace PR24587 {
1392template <typename T, T v>
1393struct integral_constant {};
1394
1395auto false_ = integral_constant<bool, false> {};
1396
1397template <typename T>
1398void f(T, decltype(false_));
1399
1400void run() {
1401 f(1, integral_constant<bool, true>{});
1402}
1403// CHECK-ELIDE-NOTREE: error: no matching function for call to 'f'
Eric Fiselierd7d79e22018-05-30 02:20:40 +00001404// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known conversion from 'integral_constant<[...], true>' to 'integral_constant<[...], false>' for 2nd argument
Richard Trieu2331c8b2016-01-15 05:48:38 +00001405}
1406
1407namespace ZeroArgs {
1408template <int N = 0> class A {};
1409template <class T = A<>> class B {};
1410A<1> a1 = A<>();
1411A<> a2 = A<1>();
1412B<> b1 = B<int>();
1413B<int> b2 = B<>();
1414B<> b3 = B<const A<>>();
1415B<const A<>> b4 = B<>();
1416// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<(default) 0>' to 'A<1>'
1417// CHECK-ELIDE-NOTREE: error: no viable conversion from 'A<1>' to 'A<(default) 0>'
1418// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<int>' to 'B<(default) ZeroArgs::A<0>>'
1419// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<(default) ZeroArgs::A<0>>' to 'B<int>'
Richard Trieu12074502016-02-02 00:36:59 +00001420// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<const A<...>>' to 'B<A<...>>'
1421// CHECK-ELIDE-NOTREE: error: no viable conversion from 'B<A<...>>' to 'B<const A<...>>'
Richard Trieu2331c8b2016-01-15 05:48:38 +00001422}
1423
Richard Trieua7564d72016-03-30 22:23:00 +00001424namespace TypeAlias {
1425
1426template <typename T> class vector {};
1427
1428template <int Dimension> class Point;
1429template <int dimension, typename T> using Polygon = vector<Point<dimension>>;
1430
1431void foo(Polygon<3, float>);
1432void bar() { foo(Polygon<2, float>()); }
1433
1434// CHECK-ELIDE-NOTREE: error: no matching function for call to 'foo'
1435// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known conversion from 'Polygon<2, [...]>' to 'Polygon<3, [...]>' for 1st argument
1436
1437enum class X {
1438 X1,
1439 X2,
1440};
1441
1442template<X x> struct EnumToType;
1443
1444template <> struct EnumToType<X::X1> { using type = int; };
1445
1446template <> struct EnumToType<X::X2> { using type = double; };
1447
1448
1449template <X x> using VectorType = vector<typename EnumToType<x>::type>;
1450
1451template <X x> void D(const VectorType<x>&);
1452
1453void run() {
1454 D<X::X1>(VectorType<X::X2>());
1455}
1456// CHECK-ELIDE-NOTREE: error: no matching function for call to 'D'
Eric Fiselierd7d79e22018-05-30 02:20:40 +00001457// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known conversion from 'VectorType<X::X2>' to 'const VectorType<(TypeAlias::X)0>' for 1st argument
Richard Trieue1a6a7d2016-08-05 03:16:36 +00001458}
Richard Trieua7564d72016-03-30 22:23:00 +00001459
Richard Trieue1a6a7d2016-08-05 03:16:36 +00001460namespace TypeAlias2 {
1461template <typename T>
1462class A {};
1463
1464template <typename T>
1465using A_reg = A<T>;
1466void take_reg(A_reg<int>);
1467
1468template <typename T>
1469using A_ptr = A<T> *;
1470void take_ptr(A_ptr<int>);
1471
1472template <typename T>
1473using A_ref = const A<T> &;
1474void take_ref(A_ref<int>);
1475
1476void run(A_reg<float> reg, A_ptr<float> ptr, A_ref<float> ref) {
1477 take_reg(reg);
1478// CHECK-ELIDE-NOTREE: error: no matching function for call to 'take_reg'
1479// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known conversion from 'A_reg<float>' to 'A_reg<int>' for 1st argument
1480
1481 take_ptr(ptr);
1482// CHECK-ELIDE-NOTREE: error: no matching function for call to 'take_ptr'
1483// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known conversion from 'A_ptr<float>' to 'A_ptr<int>' for 1st argument
1484
1485 take_ref(ref);
1486// CHECK-ELIDE-NOTREE: error: no matching function for call to 'take_ref'
1487// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known conversion from 'const A<float>' to 'const A<int>' for 1st argument
1488}
Richard Trieua7564d72016-03-30 22:23:00 +00001489}
1490
Richard Trieu91844232012-06-26 18:18:47 +00001491// CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
1492// CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
1493// CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
1494// CHECK-NOELIDE-TREE: {{[0-9]*}} errors generated.
Richard Smithe0ab8732016-10-28 19:54:43 +00001495
1496namespace pr30831 {
1497 template <typename T> struct A { static A<T> const a; };
1498 template <typename T> A<T> A<T>::a = A<T>();
1499}