diag-template-diffing.cpp 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280
  1. // 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
  5. // PR9548 - "no known conversion from 'vector<string>' to 'vector<string>'"
  6. // vector<string> refers to two different types here. Make sure the message
  7. // gives a way to tell them apart.
  8. class versa_string;
  9. typedef versa_string string;
  10. namespace std {template <typename T> class vector;}
  11. using std::vector;
  12. void f(vector<string> v);
  13. namespace std {
  14. class basic_string;
  15. typedef basic_string string;
  16. template <typename T> class vector {};
  17. void g() {
  18. vector<string> v;
  19. f(v);
  20. }
  21. } // end namespace std
  22. // CHECK-ELIDE-NOTREE: no matching function for call to 'f'
  23. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<std::basic_string>' to 'vector<versa_string>' for 1st argument
  24. // CHECK-NOELIDE-NOTREE: no matching function for call to 'f'
  25. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<std::basic_string>' to 'vector<versa_string>' for 1st argument
  26. // CHECK-ELIDE-TREE: no matching function for call to 'f'
  27. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  28. // CHECK-ELIDE-TREE: vector<
  29. // CHECK-ELIDE-TREE: [std::basic_string != versa_string]>
  30. // CHECK-NOELIDE-TREE: no matching function for call to 'f'
  31. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  32. // CHECK-NOELIDE-TREE: vector<
  33. // CHECK-NOELIDE-TREE: [std::basic_string != versa_string]>
  34. template <int... A>
  35. class I1{};
  36. void set1(I1<1,2,3,4,2,3,4,3>) {};
  37. void test1() {
  38. set1(I1<1,2,3,4,2,2,4,3,7>());
  39. }
  40. // CHECK-ELIDE-NOTREE: no matching function for call to 'set1'
  41. // 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
  42. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set1'
  43. // 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
  44. // CHECK-ELIDE-TREE: no matching function for call to 'set1'
  45. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  46. // CHECK-ELIDE-TREE: I1<
  47. // CHECK-ELIDE-TREE: [5 * ...],
  48. // CHECK-ELIDE-TREE: [2 != 3],
  49. // CHECK-ELIDE-TREE: [2 * ...],
  50. // CHECK-ELIDE-TREE: [7 != (no argument)]>
  51. // CHECK-NOELIDE-TREE: no matching function for call to 'set1'
  52. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  53. // CHECK-NOELIDE-TREE: I1<
  54. // CHECK-NOELIDE-TREE: 1,
  55. // CHECK-NOELIDE-TREE: 2,
  56. // CHECK-NOELIDE-TREE: 3,
  57. // CHECK-NOELIDE-TREE: 4,
  58. // CHECK-NOELIDE-TREE: 2,
  59. // CHECK-NOELIDE-TREE: [2 != 3],
  60. // CHECK-NOELIDE-TREE: 4,
  61. // CHECK-NOELIDE-TREE: 3,
  62. // CHECK-NOELIDE-TREE: [7 != (no argument)]>
  63. template <class A, class B, class C = void>
  64. class I2{};
  65. void set2(I2<int, int>) {};
  66. void test2() {
  67. set2(I2<double, int, int>());
  68. }
  69. // CHECK-ELIDE-NOTREE: no matching function for call to 'set2'
  70. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I2<double, [...], int>' to 'I2<int, [...], (default) void>' for 1st argument
  71. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set2'
  72. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I2<double, int, int>' to 'I2<int, int, (default) void>' for 1st argument
  73. // CHECK-ELIDE-TREE: no matching function for call to 'set2'
  74. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  75. // CHECK-ELIDE-TREE: I2<
  76. // CHECK-ELIDE-TREE: [double != int],
  77. // CHECK-ELIDE-TREE: [...],
  78. // CHECK-ELIDE-TREE: [int != (default) void]>
  79. // CHECK-NOELIDE-TREE: no matching function for call to 'set2'
  80. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  81. // CHECK-NOELIDE-TREE: I2<
  82. // CHECK-NOELIDE-TREE: [double != int],
  83. // CHECK-NOELIDE-TREE: int,
  84. // CHECK-NOELIDE-TREE: [int != (default) void]>
  85. int V1, V2, V3;
  86. template <int* A, int *B>
  87. class I3{};
  88. void set3(I3<&V1, &V2>) {};
  89. void test3() {
  90. set3(I3<&V3, &V2>());
  91. }
  92. // CHECK-ELIDE-NOTREE: no matching function for call to 'set3'
  93. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, [...]>' to 'I3<&V1, [...]>' for 1st argument
  94. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set3'
  95. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'I3<&V3, &V2>' to 'I3<&V1, &V2>' for 1st argument
  96. // CHECK-ELIDE-TREE: no matching function for call to 'set3'
  97. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  98. // CHECK-ELIDE-TREE: I3<
  99. // CHECK-ELIDE-TREE: [&V3 != &V1]
  100. // CHECK-ELIDE-TREE: [...]>
  101. // CHECK-NOELIDE-TREE: no matching function for call to 'set3'
  102. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  103. // CHECK-NOELIDE-TREE: I3<
  104. // CHECK-NOELIDE-TREE: [&V3 != &V1]
  105. // CHECK-NOELIDE-TREE: &V2>
  106. template <class A, class B>
  107. class Alpha{};
  108. template <class A, class B>
  109. class Beta{};
  110. template <class A, class B>
  111. class Gamma{};
  112. template <class A, class B>
  113. class Delta{};
  114. void set4(Alpha<int, int>);
  115. void test4() {
  116. set4(Beta<void, void>());
  117. }
  118. // CHECK-ELIDE-NOTREE: no matching function for call to 'set4'
  119. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
  120. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set4'
  121. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
  122. // CHECK-ELIDE-TREE: no matching function for call to 'set4'
  123. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
  124. // CHECK-NOELIDE-TREE: no matching function for call to 'set4'
  125. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from 'Beta<void, void>' to 'Alpha<int, int>' for 1st argument
  126. void set5(Alpha<Beta<Gamma<Delta<int, int>, int>, int>, int>);
  127. void test5() {
  128. set5(Alpha<Beta<Gamma<void, void>, double>, double>());
  129. }
  130. // CHECK-ELIDE-NOTREE: no matching function for call to 'set5'
  131. // 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
  132. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set5'
  133. // 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
  134. // CHECK-ELIDE-TREE: no matching function for call to 'set5'
  135. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  136. // CHECK-ELIDE-TREE: Alpha<
  137. // CHECK-ELIDE-TREE: Beta<
  138. // CHECK-ELIDE-TREE: Gamma<
  139. // CHECK-ELIDE-TREE: [void != Delta<int, int>],
  140. // CHECK-ELIDE-TREE: [void != int]>
  141. // CHECK-ELIDE-TREE: [double != int]>
  142. // CHECK-ELIDE-TREE: [double != int]>
  143. // CHECK-NOELIDE-TREE: no matching function for call to 'set5'
  144. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  145. // CHECK-NOELIDE-TREE: Alpha<
  146. // CHECK-NOELIDE-TREE: Beta<
  147. // CHECK-NOELIDE-TREE: Gamma<
  148. // CHECK-NOELIDE-TREE: [void != Delta<int, int>],
  149. // CHECK-NOELIDE-TREE: [void != int]>
  150. // CHECK-NOELIDE-TREE: [double != int]>
  151. // CHECK-NOELIDE-TREE: [double != int]>
  152. void test6() {
  153. set5(Alpha<Beta<Delta<int, int>, int>, int>());
  154. }
  155. // CHECK-ELIDE-NOTREE: no matching function for call to 'set5'
  156. // 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
  157. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set5'
  158. // 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
  159. // CHECK-ELIDE-TREE: no matching function for call to 'set5'
  160. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  161. // CHECK-ELIDE-TREE: Alpha<
  162. // CHECK-ELIDE-TREE: Beta<
  163. // CHECK-ELIDE-TREE: [Delta<int, int> != Gamma<Delta<int, int>, int>],
  164. // CHECK-ELIDE-TREE: [...]>
  165. // CHECK-ELIDE-TREE: [...]>
  166. // CHECK-NOELIDE-TREE: no matching function for call to 'set5'
  167. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  168. // CHECK-NOELIDE-TREE: Alpha<
  169. // CHECK-NOELIDE-TREE: Beta<
  170. // CHECK-NOELIDE-TREE: [Delta<int, int> != Gamma<Delta<int, int>, int>],
  171. // CHECK-NOELIDE-TREE: int>
  172. // CHECK-NOELIDE-TREE: int>
  173. int a7, b7;
  174. int c7[] = {1,2,3};
  175. template<int *A>
  176. class class7 {};
  177. void set7(class7<&a7> A) {}
  178. void test7() {
  179. set7(class7<&a7>());
  180. set7(class7<&b7>());
  181. set7(class7<c7>());
  182. set7(class7<nullptr>());
  183. }
  184. // CHECK-ELIDE-NOTREE: no matching function for call to 'set7'
  185. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument
  186. // CHECK-ELIDE-NOTREE: no matching function for call to 'set7'
  187. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<c7>' to 'class7<&a7>' for 1st argument
  188. // CHECK-ELIDE-NOTREE: no matching function for call to 'set7'
  189. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<nullptr>' to 'class7<&a7>' for 1st argument
  190. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set7'
  191. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<&b7>' to 'class7<&a7>' for 1st argument
  192. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set7'
  193. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<c7>' to 'class7<&a7>' for 1st argument
  194. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set7'
  195. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class7<nullptr>' to 'class7<&a7>' for 1st argument
  196. // CHECK-ELIDE-TREE: no matching function for call to 'set7'
  197. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  198. // CHECK-ELIDE-TREE: class7<
  199. // CHECK-ELIDE-TREE: [&b7 != &a7]>
  200. // CHECK-ELIDE-TREE: no matching function for call to 'set7'
  201. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  202. // CHECK-ELIDE-TREE: class7<
  203. // CHECK-ELIDE-TREE: [c7 != &a7]>
  204. // CHECK-ELIDE-TREE: no matching function for call to 'set7'
  205. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  206. // CHECK-ELIDE-TREE: class7<
  207. // CHECK-ELIDE-TREE: [nullptr != &a7]>
  208. // CHECK-NOELIDE-TREE: no matching function for call to 'set7'
  209. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  210. // CHECK-NOELIDE-TREE: class7<
  211. // CHECK-NOELIDE-TREE: [&b7 != &a7]>
  212. // CHECK-NOELIDE-TREE: no matching function for call to 'set7'
  213. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  214. // CHECK-NOELIDE-TREE: class7<
  215. // CHECK-NOELIDE-TREE: [c7 != &a7]>
  216. // CHECK-NOELIDE-TREE: no matching function for call to 'set7'
  217. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  218. // CHECK-NOELIDE-TREE: class7<
  219. // CHECK-NOELIDE-TREE: [nullptr != &a7]>
  220. template<typename ...T> struct S8 {};
  221. template<typename T> using U8 = S8<int, char, T>;
  222. int f8(S8<int, char, double>);
  223. int k8 = f8(U8<char>());
  224. // CHECK-ELIDE-NOTREE: no matching function for call to 'f8'
  225. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<[2 * ...], char>' to 'S8<[2 * ...], double>' for 1st argument
  226. // CHECK-NOELIDE-NOTREE: no matching function for call to 'f8'
  227. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S8<int, char, char>' to 'S8<int, char, double>' for 1st argument
  228. // CHECK-ELIDE-TREE: no matching function for call to 'f8'
  229. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  230. // CHECK-ELIDE-TREE: S8<
  231. // CHECK-ELIDE-TREE: [2 * ...],
  232. // CHECK-ELIDE-TREE: [char != double]>
  233. // CHECK-NOELIDE-TREE: no matching function for call to 'f8'
  234. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  235. // CHECK-NOELIDE-TREE: S8<
  236. // CHECK-NOELIDE-TREE: int,
  237. // CHECK-NOELIDE-TREE: char,
  238. // CHECK-NOELIDE-TREE: [char != double]>
  239. template<typename ...T> struct S9 {};
  240. template<typename T> using U9 = S9<int, char, T>;
  241. template<typename T> using V9 = U9<U9<T>>;
  242. int f9(S9<int, char, U9<const double>>);
  243. int k9 = f9(V9<double>());
  244. // CHECK-ELIDE-NOTREE: no matching function for call to 'f9'
  245. // 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
  246. // CHECK-NOELIDE-NOTREE: no matching function for call to 'f9'
  247. // 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
  248. // CHECK-ELIDE-TREE: no matching function for call to 'f9'
  249. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  250. // CHECK-ELIDE-TREE: S9<
  251. // CHECK-ELIDE-TREE: [2 * ...],
  252. // CHECK-ELIDE-TREE: S9<
  253. // CHECK-ELIDE-TREE: [2 * ...],
  254. // CHECK-ELIDE-TREE: [double != const double]>>
  255. // CHECK-NOELIDE-TREE: no matching function for call to 'f9'
  256. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  257. // CHECK-NOELIDE-TREE: S9<
  258. // CHECK-NOELIDE-TREE: int,
  259. // CHECK-NOELIDE-TREE: char,
  260. // CHECK-NOELIDE-TREE: S9<
  261. // CHECK-NOELIDE-TREE: int,
  262. // CHECK-NOELIDE-TREE: char,
  263. // CHECK-NOELIDE-TREE: [double != const double]>>
  264. template<typename ...A> class class_types {};
  265. void set10(class_types<int, int>) {}
  266. void test10() {
  267. set10(class_types<int>());
  268. set10(class_types<int, int, int>());
  269. }
  270. // CHECK-ELIDE-NOTREE: no matching function for call to 'set10'
  271. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[...], (no argument)>' to 'class_types<[...], int>' for 1st argument
  272. // CHECK-ELIDE-NOTREE: no matching function for call to 'set10'
  273. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<[2 * ...], int>' to 'class_types<[2 * ...], (no argument)>' for 1st argument
  274. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set10'
  275. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_types<int, (no argument)>' to 'class_types<int, int>' for 1st argument
  276. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set10'
  277. // 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
  278. // CHECK-ELIDE-TREE: no matching function for call to 'set10'
  279. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  280. // CHECK-ELIDE-TREE: class_types<
  281. // CHECK-ELIDE-TREE: [...],
  282. // CHECK-ELIDE-TREE: [(no argument) != int]>
  283. // CHECK-ELIDE-TREE: no matching function for call to 'set10'
  284. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  285. // CHECK-ELIDE-TREE: class_types<
  286. // CHECK-ELIDE-TREE: [2 * ...],
  287. // CHECK-ELIDE-TREE: [int != (no argument)]>
  288. // CHECK-NOELIDE-TREE: no matching function for call to 'set10'
  289. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  290. // CHECK-NOELIDE-TREE: class_types<
  291. // CHECK-NOELIDE-TREE: int,
  292. // CHECK-NOELIDE-TREE: [(no argument) != int]>
  293. // CHECK-NOELIDE-TREE: no matching function for call to 'set10'
  294. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  295. // CHECK-NOELIDE-TREE: class_types<
  296. // CHECK-NOELIDE-TREE: int,
  297. // CHECK-NOELIDE-TREE: int,
  298. // CHECK-NOELIDE-TREE: [int != (no argument)]>
  299. template<int ...A> class class_ints {};
  300. void set11(class_ints<2, 3>) {}
  301. void test11() {
  302. set11(class_ints<1>());
  303. set11(class_ints<0, 3, 6>());
  304. }
  305. // CHECK-ELIDE-NOTREE: no matching function for call to 'set11'
  306. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument
  307. // CHECK-ELIDE-NOTREE: no matching function for call to 'set11'
  308. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<0, [...], 6>' to 'class_ints<2, [...], (no argument)>' for 1st argument
  309. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set11'
  310. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ints<1, (no argument)>' to 'class_ints<2, 3>' for 1st argument
  311. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set11'
  312. // 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
  313. // CHECK-ELIDE-TREE: no matching function for call to 'set11'
  314. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  315. // CHECK-ELIDE-TREE: class_ints<
  316. // CHECK-ELIDE-TREE: [1 != 2],
  317. // CHECK-ELIDE-TREE: [(no argument) != 3]>
  318. // CHECK-ELIDE-TREE: no matching function for call to 'set11'
  319. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  320. // CHECK-ELIDE-TREE: class_ints<
  321. // CHECK-ELIDE-TREE: [0 != 2],
  322. // CHECK-ELIDE-TREE: [...],
  323. // CHECK-ELIDE-TREE: [6 != (no argument)]>
  324. // CHECK-NOELIDE-TREE: no matching function for call to 'set11'
  325. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  326. // CHECK-NOELIDE-TREE: class_ints<
  327. // CHECK-NOELIDE-TREE: [1 != 2],
  328. // CHECK-NOELIDE-TREE: [(no argument) != 3]>
  329. // CHECK-NOELIDE-TREE: no matching function for call to 'set11'
  330. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  331. // CHECK-NOELIDE-TREE: class_ints<
  332. // CHECK-NOELIDE-TREE: [0 != 2],
  333. // CHECK-NOELIDE-TREE: 3,
  334. // CHECK-NOELIDE-TREE: [6 != (no argument)]>
  335. template<template<class> class ...A> class class_template_templates {};
  336. template<class> class tt1 {};
  337. template<class> class tt2 {};
  338. void set12(class_template_templates<tt1, tt1>) {}
  339. void test12() {
  340. set12(class_template_templates<tt2>());
  341. set12(class_template_templates<tt1, tt1, tt1>());
  342. }
  343. // CHECK-ELIDE-NOTREE: no matching function for call to 'set12'
  344. // 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
  345. // CHECK-ELIDE-NOTREE: no matching function for call to 'set12'
  346. // 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
  347. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set12'
  348. // 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
  349. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set12'
  350. // 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
  351. // CHECK-ELIDE-TREE: no matching function for call to 'set12'
  352. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  353. // CHECK-ELIDE-TREE: class_template_templates<
  354. // CHECK-ELIDE-TREE: [template tt2 != template tt1],
  355. // CHECK-ELIDE-TREE: [template (no argument) != template tt1]>
  356. // CHECK-ELIDE-TREE: no matching function for call to 'set12'
  357. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  358. // CHECK-ELIDE-TREE: class_template_templates<
  359. // CHECK-ELIDE-TREE: [2 * ...],
  360. // CHECK-ELIDE-TREE: [template tt1 != template (no argument)]>
  361. // CHECK-NOELIDE-TREE: no matching function for call to 'set12'
  362. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  363. // CHECK-NOELIDE-TREE: class_template_templates<
  364. // CHECK-NOELIDE-TREE: [template tt2 != template tt1],
  365. // CHECK-NOELIDE-TREE: [template (no argument) != template tt1]>
  366. // CHECK-NOELIDE-TREE: no matching function for call to 'set12'
  367. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  368. // CHECK-NOELIDE-TREE: class_template_templates<
  369. // CHECK-NOELIDE-TREE: template tt1,
  370. // CHECK-NOELIDE-TREE: template tt1,
  371. // CHECK-NOELIDE-TREE: [template tt1 != template (no argument)]>
  372. double a13, b13, c13, d13;
  373. template<double* ...A> class class_ptrs {};
  374. void set13(class_ptrs<&a13, &b13>) {}
  375. void test13() {
  376. set13(class_ptrs<&c13>());
  377. set13(class_ptrss<&a13, &b13, &d13>());
  378. }
  379. // CHECK-ELIDE-NOTREE: no matching function for call to 'set13'
  380. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&c13, (no argument)>' to 'class_ptrs<&a13, &b13>' for 1st argument
  381. // CHECK-ELIDE-NOTREE: no matching function for call to 'set13'
  382. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<[2 * ...], &d13>' to 'class_ptrs<[2 * ...], (no argument)>' for 1st argument
  383. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set13'
  384. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'class_ptrs<&c13, (no argument)>' to 'class_ptrs<&a13, &b13>' for 1st argument
  385. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set13'
  386. // 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
  387. // CHECK-ELIDE-TREE: no matching function for call to 'set13'
  388. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  389. // CHECK-ELIDE-TREE: class_ptrs<
  390. // CHECK-ELIDE-TREE: [&c13 != &a13],
  391. // CHECK-ELIDE-TREE: [(no argument) != &b13]>
  392. // CHECK-ELIDE-TREE: no matching function for call to 'set13'
  393. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  394. // CHECK-ELIDE-TREE: class_ptrs<
  395. // CHECK-ELIDE-TREE: [2 * ...],
  396. // CHECK-ELIDE-TREE: [&d13 != (no argument)]>
  397. // CHECK-NOELIDE-TREE: no matching function for call to 'set13'
  398. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  399. // CHECK-NOELIDE-TREE: class_ptrs<
  400. // CHECK-NOELIDE-TREE: [&c13 != &a13],
  401. // CHECK-NOELIDE-TREE: [(no argument) != &b13]>
  402. // CHECK-NOELIDE-TREE: no matching function for call to 'set13'
  403. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  404. // CHECK-NOELIDE-TREE: class_ptrs<
  405. // CHECK-NOELIDE-TREE: &a13,
  406. // CHECK-NOELIDE-TREE: &b13,
  407. // CHECK-NOELIDE-TREE: [&d13 != (no argument)]>
  408. template<typename T> struct s14 {};
  409. template<typename T> using a14 = s14<T>;
  410. typedef a14<int> b14;
  411. template<typename T> using c14 = b14;
  412. int f14(c14<int>);
  413. int k14 = f14(a14<char>());
  414. // CHECK-ELIDE-NOTREE: no matching function for call to 'f14'
  415. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'a14<char>' to 'a14<int>' for 1st argument
  416. // CHECK-NOELIDE-NOTREE: no matching function for call to 'f14'
  417. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'a14<char>' to 'a14<int>' for 1st argument
  418. // CHECK-ELIDE-TREE: no matching function for call to 'f14'
  419. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  420. // CHECK-ELIDE-TREE: a14<
  421. // CHECK-ELIDE-TREE: [char != int]>
  422. // CHECK-NOELIDE-TREE: no matching function for call to 'f14'
  423. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  424. // CHECK-NOELIDE-TREE: a14<
  425. // CHECK-NOELIDE-TREE: [char != int]>
  426. void set15(vector<vector<int>>) {}
  427. void test15() {
  428. set15(vector<vector<int>>());
  429. }
  430. // CHECK-ELIDE-NOTREE-NOT: set15
  431. // CHECK-NOELIDE-NOTREE-NOT: set15
  432. // CHECK-ELIDE-TREE-NOT: set15
  433. // CHECK-NOELIDE-TREE-NOT: set15
  434. // no error here
  435. void set16(vector<const vector<int>>) {}
  436. void test16() {
  437. set16(vector<const vector<const int>>());
  438. }
  439. // CHECK-ELIDE-NOTREE: no matching function for call to 'set16'
  440. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<const int>>' to 'vector<const vector<int>>' for 1st argument
  441. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set16'
  442. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<const int>>' to 'vector<const vector<int>>' for 1st argument
  443. // CHECK-ELIDE-TREE: no matching function for call to 'set16'
  444. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  445. // CHECK-ELIDE-TREE: vector<
  446. // CHECK-ELIDE-TREE: const vector<
  447. // CHECK-ELIDE-TREE: [const != (no qualifiers)] int>>
  448. // CHECK-NOELIDE-TREE: no matching function for call to 'set16'
  449. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  450. // CHECK-NOELIDE-TREE: vector<
  451. // CHECK-NOELIDE-TREE: const vector<
  452. // CHECK-NOELIDE-TREE: [const != (no qualifiers)] int>>
  453. void set17(vector<vector<int>>) {}
  454. void test17() {
  455. set17(vector<const vector<int>>());
  456. }
  457. // CHECK-ELIDE-NOTREE: no matching function for call to 'set17'
  458. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<[...]>>' to 'vector<vector<[...]>>' for 1st argument
  459. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set17'
  460. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<int>>' to 'vector<vector<int>>' for 1st argument
  461. // CHECK-ELIDE-TREE: no matching function for call to 'set17'
  462. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  463. // CHECK-ELIDE-TREE: vector<
  464. // CHECK-ELIDE-TREE: [const != (no qualifiers)] vector<
  465. // CHECK-ELIDE-TREE: [...]>>
  466. // CHECK-NOELIDE-TREE: no matching function for call to 'set17'
  467. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  468. // CHECK-NOELIDE-TREE: vector<
  469. // CHECK-NOELIDE-TREE: [const != (no qualifiers)] vector<
  470. // CHECK-NOELIDE-TREE: int>>
  471. void set18(vector<const vector<int>>) {}
  472. void test18() {
  473. set18(vector<vector<int>>());
  474. }
  475. // CHECK-ELIDE-NOTREE: no matching function for call to 'set18'
  476. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<vector<[...]>>' to 'vector<const vector<[...]>>' for 1st argument
  477. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set18'
  478. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<vector<int>>' to 'vector<const vector<int>>' for 1st argument
  479. // CHECK-ELIDE-TREE: no matching function for call to 'set18'
  480. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  481. // CHECK-ELIDE-TREE: vector<
  482. // CHECK-ELIDE-TREE: [(no qualifiers) != const] vector<
  483. // CHECK-ELIDE-TREE: [...]>>
  484. // CHECK-NOELIDE-TREE: no matching function for call to 'set18'
  485. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  486. // CHECK-NOELIDE-TREE: vector<
  487. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] vector<
  488. // CHECK-NOELIDE-TREE: int>>
  489. void set19(vector<volatile vector<int>>) {}
  490. void test19() {
  491. set19(vector<const vector<int>>());
  492. }
  493. // CHECK-ELIDE-NOTREE: no matching function for call to 'set19'
  494. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<[...]>>' to 'vector<volatile vector<[...]>>' for 1st argument
  495. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set19'
  496. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<int>>' to 'vector<volatile vector<int>>' for 1st argument
  497. // CHECK-ELIDE-TREE: no matching function for call to 'set19'
  498. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  499. // CHECK-ELIDE-TREE: vector<
  500. // CHECK-ELIDE-TREE: [const != volatile] vector<
  501. // CHECK-ELIDE-TREE: [...]>>
  502. // CHECK-NOELIDE-TREE: no matching function for call to 'set19'
  503. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  504. // CHECK-NOELIDE-TREE: vector<
  505. // CHECK-NOELIDE-TREE: [const != volatile] vector<
  506. // CHECK-NOELIDE-TREE: int>>
  507. void set20(vector<const volatile vector<int>>) {}
  508. void test20() {
  509. set20(vector<const vector<int>>());
  510. }
  511. // CHECK-ELIDE-NOTREE: no matching function for call to 'set20'
  512. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<[...]>>' to 'vector<const volatile vector<[...]>>' for 1st argument
  513. // CHECK-NOELIDE-NOTREE: no matching function for call to 'set20'
  514. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<const vector<int>>' to 'vector<const volatile vector<int>>' for 1st argument
  515. // CHECK-ELIDE-TREE: no matching function for call to 'set20'
  516. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  517. // CHECK-ELIDE-TREE: vector<
  518. // CHECK-ELIDE-TREE: [const != const volatile] vector<
  519. // CHECK-ELIDE-TREE: [...]>>
  520. // CHECK-NOELIDE-TREE: no matching function for call to 'set20'
  521. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  522. // CHECK-NOELIDE-TREE: vector<
  523. // CHECK-NOELIDE-TREE: [const != const volatile] vector<
  524. // CHECK-NOELIDE-TREE: int>>
  525. // Checks that volatile does not show up in diagnostics.
  526. template<typename T> struct S21 {};
  527. template<typename T> using U21 = volatile S21<T>;
  528. int f21(vector<const U21<int>>);
  529. int k21 = f21(vector<U21<int>>());
  530. // CHECK-ELIDE-NOTREE: no matching function for call to 'f21'
  531. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U21<[...]>>' to 'vector<const U21<[...]>>' for 1st argument
  532. // CHECK-NOELIDE-NOTREE: no matching function for call to 'f21'
  533. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U21<int>>' to 'vector<const U21<int>>' for 1st argument
  534. // CHECK-ELIDE-TREE: no matching function for call to 'f21'
  535. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  536. // CHECK-ELIDE-TREE: vector<
  537. // CHECK-ELIDE-TREE: [(no qualifiers) != const] U21<
  538. // CHECK-ELIDE-TREE: [...]>>
  539. // CHECK-NOELIDE-TREE: no matching function for call to 'f21'
  540. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  541. // CHECK-NOELIDE-TREE: vector<
  542. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] U21<
  543. // CHECK-NOELIDE-TREE: int>>
  544. // Checks that volatile does not show up in diagnostics.
  545. template<typename T> struct S22 {};
  546. template<typename T> using U22 = volatile S22<T>;
  547. int f22(vector<volatile const U22<int>>);
  548. int k22 = f22(vector<volatile U22<int>>());
  549. // CHECK-ELIDE-NOTREE: no matching function for call to 'f22'
  550. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U22<[...]>>' to 'vector<const U22<[...]>>' for 1st argument
  551. // CHECK-NOELIDE-NOTREE: no matching function for call to 'f22'
  552. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'vector<U22<int>>' to 'vector<const U22<int>>' for 1st argument
  553. // CHECK-ELIDE-TREE: no matching function for call to 'f22'
  554. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  555. // CHECK-ELIDE-TREE: vector<
  556. // CHECK-ELIDE-TREE: [(no qualifiers) != const] U22<
  557. // CHECK-ELIDE-TREE: [...]>>
  558. // CHECK-NOELIDE-TREE: no matching function for call to 'f22'
  559. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  560. // CHECK-NOELIDE-TREE: vector<
  561. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] U22<
  562. // CHECK-NOELIDE-TREE: int>>
  563. // Testing qualifiers and typedefs.
  564. template <class T> struct D23{};
  565. template <class T> using C23 = D23<T>;
  566. typedef const C23<int> B23;
  567. template<class ...T> using A23 = B23;
  568. void foo23(D23<A23<>> b) {}
  569. void test23() {
  570. foo23(D23<D23<char>>());
  571. foo23(C23<char>());
  572. }
  573. // CHECK-ELIDE-NOTREE: no matching function for call to 'foo23'
  574. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<D23<char>>' to 'D23<const D23<int>>' for 1st argument
  575. // CHECK-ELIDE-NOTREE: no matching function for call to 'foo23'
  576. // CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<char>' to 'D23<A23<>>' for 1st argument
  577. // CHECK-NOELIDE-NOTREE: no matching function for call to 'foo23'
  578. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<D23<char>>' to 'D23<const D23<int>>' for 1st argument
  579. // CHECK-NOELIDE-NOTREE: no matching function for call to 'foo23'
  580. // CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'D23<char>' to 'D23<A23<>>' for 1st argument
  581. // CHECK-ELIDE-TREE: no matching function for call to 'foo23'
  582. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  583. // CHECK-ELIDE-TREE: D23<
  584. // CHECK-ELIDE-TREE: [(no qualifiers) != const] D23<
  585. // CHECK-ELIDE-TREE: [char != int]>>
  586. // CHECK-ELIDE-TREE: no matching function for call to 'foo23'
  587. // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  588. // CHECK-ELIDE-TREE: D23<
  589. // CHECK-ELIDE-TREE: [char != A23<>]>
  590. // CHECK-NOELIDE-TREE: no matching function for call to 'foo23'
  591. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  592. // CHECK-NOELIDE-TREE: D23<
  593. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] D23<
  594. // CHECK-NOELIDE-TREE: [char != int]>>
  595. // CHECK-NOELIDE-TREE: no matching function for call to 'foo23'
  596. // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument
  597. // CHECK-NOELIDE-TREE: D23<
  598. // CHECK-NOELIDE-TREE: [char != A23<>]>
  599. namespace PR14015 {
  600. template <unsigned N> class Foo1 {};
  601. template <unsigned N = 2> class Foo2 {};
  602. template <unsigned ...N> class Foo3 {};
  603. void Play1() {
  604. Foo1<1> F1;
  605. Foo1<2> F2, F3;
  606. F2 = F1;
  607. F1 = F2;
  608. F2 = F3;
  609. F3 = F2;
  610. }
  611. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  612. // 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
  613. // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
  614. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  615. // 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
  616. // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
  617. // CHECK-NOELIDE-NOTREE: no viable overloaded '='
  618. // 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
  619. // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<1>' to 'Foo1<2>' for 1st argument
  620. // CHECK-NOELIDE-NOTREE: no viable overloaded '='
  621. // 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
  622. // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo1<2>' to 'Foo1<1>' for 1st argument
  623. // CHECK-ELIDE-TREE: no viable overloaded '='
  624. // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  625. // CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1<
  626. // CHECK-ELIDE-TREE: [1 != 2]>
  627. // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  628. // CHECK-ELIDE-TREE: Foo1<
  629. // CHECK-ELIDE-TREE: [1 != 2]>
  630. // CHECK-ELIDE-TREE: no viable overloaded '='
  631. // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  632. // CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo1<
  633. // CHECK-ELIDE-TREE: [2 != 1]>
  634. // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  635. // CHECK-ELIDE-TREE: Foo1<
  636. // CHECK-ELIDE-TREE: [2 != 1]>
  637. // CHECK-NOELIDE-TREE: no viable overloaded '='
  638. // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  639. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1<
  640. // CHECK-NOELIDE-TREE: [1 != 2]>
  641. // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  642. // CHECK-NOELIDE-TREE: Foo1<
  643. // CHECK-NOELIDE-TREE: [1 != 2]>
  644. // CHECK-NOELIDE-TREE: no viable overloaded '='
  645. // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  646. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo1<
  647. // CHECK-NOELIDE-TREE: [2 != 1]>
  648. // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  649. // CHECK-NOELIDE-TREE: Foo1<
  650. // CHECK-NOELIDE-TREE: [2 != 1]>
  651. void Play2() {
  652. Foo2<1> F1;
  653. Foo2<> F2, F3;
  654. F2 = F1;
  655. F1 = F2;
  656. F2 = F3;
  657. F3 = F2;
  658. }
  659. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  660. // 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
  661. // CHECK-ELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
  662. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  663. // 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
  664. // 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
  665. // CHECK-NOELIDE-NOTREE: no viable overloaded '='
  666. // 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
  667. // CHECK-NOELIDE-NOTREE: candidate function (the implicit move assignment operator) not viable: no known conversion from 'Foo2<1>' to 'Foo2<2>' for 1st argument
  668. // CHECK-NOELIDE-NOTREE: no viable overloaded '='
  669. // 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
  670. // 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
  671. // CHECK-ELIDE-TREE: no viable overloaded '='
  672. // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  673. // CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2<
  674. // CHECK-ELIDE-TREE: [1 != 2]>
  675. // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  676. // CHECK-ELIDE-TREE: Foo2<
  677. // CHECK-ELIDE-TREE: [1 != 2]>
  678. // CHECK-ELIDE-TREE: no viable overloaded '='
  679. // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  680. // CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo2<
  681. // CHECK-ELIDE-TREE: [(default) 2 != 1]>
  682. // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  683. // CHECK-ELIDE-TREE: Foo2<
  684. // CHECK-ELIDE-TREE: [(default) 2 != 1]>
  685. // CHECK-NOELIDE-TREE: no viable overloaded '='
  686. // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  687. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2<
  688. // CHECK-NOELIDE-TREE: [1 != 2]>
  689. // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  690. // CHECK-NOELIDE-TREE: Foo2<
  691. // CHECK-NOELIDE-TREE: [1 != 2]>
  692. // CHECK-NOELIDE-TREE: no viable overloaded '='
  693. // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  694. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo2<
  695. // CHECK-NOELIDE-TREE: [(default) 2 != 1]>
  696. // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  697. // CHECK-NOELIDE-TREE: Foo2<
  698. // CHECK-NOELIDE-TREE: [(default) 2 != 1]>
  699. void Play3() {
  700. Foo3<1> F1;
  701. Foo3<2, 1> F2, F3;
  702. F2 = F1;
  703. F1 = F2;
  704. F2 = F3;
  705. F3 = F2;
  706. }
  707. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  708. // 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
  709. // 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
  710. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  711. // 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
  712. // 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
  713. // CHECK-NOELIDE-NOTREE: no viable overloaded '='
  714. // 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
  715. // 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
  716. // CHECK-NOELIDE-NOTREE: no viable overloaded '='
  717. // 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
  718. // 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
  719. // CHECK-ELIDE-TREE: no viable overloaded '='
  720. // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  721. // CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3<
  722. // CHECK-ELIDE-TREE: [1 != 2],
  723. // CHECK-ELIDE-TREE: [(no argument) != 1]>
  724. // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  725. // CHECK-ELIDE-TREE: Foo3<
  726. // CHECK-ELIDE-TREE: [1 != 2],
  727. // CHECK-ELIDE-TREE: [(no argument) != 1]>
  728. // CHECK-ELIDE-TREE: no viable overloaded '='
  729. // CHECK-ELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  730. // CHECK-ELIDE-TREE: [(no qualifiers) != const] Foo3<
  731. // CHECK-ELIDE-TREE: [2 != 1],
  732. // CHECK-ELIDE-TREE: [1 != (no argument)]>
  733. // CHECK-ELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  734. // CHECK-ELIDE-TREE: Foo3<
  735. // CHECK-ELIDE-TREE: [2 != 1],
  736. // CHECK-ELIDE-TREE: [1 != (no argument)]>
  737. // CHECK-NOELIDE-TREE: no viable overloaded '='
  738. // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  739. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3<
  740. // CHECK-NOELIDE-TREE: [1 != 2],
  741. // CHECK-NOELIDE-TREE: [(no argument) != 1]>
  742. // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  743. // CHECK-NOELIDE-TREE: Foo3<
  744. // CHECK-NOELIDE-TREE: [1 != 2],
  745. // CHECK-NOELIDE-TREE: [(no argument) != 1]>
  746. // CHECK-NOELIDE-TREE: no viable overloaded '='
  747. // CHECK-NOELIDE-TREE: candidate function (the implicit copy assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  748. // CHECK-NOELIDE-TREE: [(no qualifiers) != const] Foo3<
  749. // CHECK-NOELIDE-TREE: [2 != 1],
  750. // CHECK-NOELIDE-TREE: [1 != (no argument)]>
  751. // CHECK-NOELIDE-TREE: candidate function (the implicit move assignment operator) not viable: no known conversion from argument type to parameter type for 1st argument
  752. // CHECK-NOELIDE-TREE: Foo3<
  753. // CHECK-NOELIDE-TREE: [2 != 1],
  754. // CHECK-NOELIDE-TREE: [1 != (no argument)]>
  755. }
  756. namespace PR14342 {
  757. template<typename T, short a> struct X {};
  758. X<int, (signed char)-1> x = X<long, -1>();
  759. X<int, 3UL> y = X<int, 2>();
  760. // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<long, [...]>' to 'X<int, [...]>'
  761. // CHECK-ELIDE-NOTREE: error: no viable conversion from 'X<[...], 2>' to 'X<[...], 3>'
  762. }
  763. namespace PR14489 {
  764. // The important thing here is that the diagnostic diffs a template specialization
  765. // with no arguments against itself. (We might need a different test if this
  766. // diagnostic changes).
  767. template<class ...V>
  768. struct VariableList {
  769. void ConnectAllToAll(VariableList<>& params = VariableList<>()) {
  770. }
  771. };
  772. // CHECK-ELIDE-NOTREE: non-const lvalue reference to type 'VariableList<>' cannot bind to a temporary of type 'VariableList<>'
  773. }
  774. namespace rdar12456626 {
  775. struct IntWrapper {
  776. typedef int type;
  777. };
  778. template<typename T, typename T::type V>
  779. struct X { };
  780. struct A {
  781. virtual X<IntWrapper, 1> foo();
  782. };
  783. struct B : A {
  784. // CHECK-ELIDE-NOTREE: virtual function 'foo' has a different return type
  785. virtual X<IntWrapper, 2> foo();
  786. };
  787. }
  788. namespace PR15023 {
  789. // Don't crash when non-QualTypes are passed to a diff modifier.
  790. template <typename... Args>
  791. void func(void (*func)(Args...), Args...) { }
  792. void bar(int, int &) {
  793. }
  794. void foo(int x) {
  795. func(bar, 1, x)
  796. }
  797. // CHECK-ELIDE-NOTREE: no matching function for call to 'func'
  798. // CHECK-ELIDE-NOTREE: candidate template ignored: deduced conflicting types for parameter 'Args' (<int, int &> vs. <int, int>)
  799. }
  800. namespace rdar12931988 {
  801. namespace A {
  802. template<typename T> struct X { };
  803. }
  804. namespace B {
  805. template<typename T> struct X { };
  806. }
  807. void foo(A::X<int> &ax, B::X<int> bx) {
  808. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  809. // CHECK-ELIDE-NOTREE: no known conversion from 'B::X<int>' to 'const rdar12931988::A::X<int>'
  810. ax = bx;
  811. }
  812. template<template<typename> class> class Y {};
  813. void bar(Y<A::X> ya, Y<B::X> yb) {
  814. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  815. // CHECK-ELIDE-NOTREE: no known conversion from 'Y<template rdar12931988::B::X>' to 'Y<template rdar12931988::A::X>'
  816. ya = yb;
  817. }
  818. }
  819. namespace ValueDecl {
  820. int int1, int2, default_int;
  821. template <const int& T = default_int>
  822. struct S {};
  823. typedef S<int1> T1;
  824. typedef S<int2> T2;
  825. typedef S<> TD;
  826. void test() {
  827. T1 t1;
  828. T2 t2;
  829. TD td;
  830. t1 = t2;
  831. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  832. // CHECK-ELIDE-NOTREE: no known conversion from 'S<int2>' to 'S<int1>'
  833. t2 = t1;
  834. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  835. // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<int2>'
  836. td = t1;
  837. // TODO: Find out why (default) isn't printed on second template.
  838. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  839. // CHECK-ELIDE-NOTREE: no known conversion from 'S<int1>' to 'S<default_int>'
  840. t2 = td;
  841. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  842. // CHECK-ELIDE-NOTREE: no known conversion from 'S<(default) default_int>' to 'S<int2>'
  843. }
  844. }
  845. namespace DependentDefault {
  846. template <typename> struct Trait {
  847. enum { V = 40 };
  848. typedef int Ty;
  849. static int I;
  850. };
  851. int other;
  852. template <typename T, int = Trait<T>::V > struct A {};
  853. template <typename T, typename = Trait<T>::Ty > struct B {};
  854. template <typename T, int& = Trait<T>::I > struct C {};
  855. void test() {
  856. A<int> a1;
  857. A<char> a2;
  858. A<int, 10> a3;
  859. a1 = a2;
  860. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  861. // CHECK-ELIDE-NOTREE: no known conversion from 'A<char, [...]>' to 'A<int, [...]>'
  862. a3 = a1;
  863. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  864. // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (default) 40>' to 'A<[...], 10>'
  865. a2 = a3;
  866. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  867. // CHECK-ELIDE-NOTREE: no known conversion from 'A<int, 10>' to 'A<char, 40>'
  868. B<int> b1;
  869. B<char> b2;
  870. B<int, char> b3;
  871. b1 = b2;
  872. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  873. // CHECK-ELIDE-NOTREE: no known conversion from 'B<char, [...]>' to 'B<int, [...]>'
  874. b3 = b1;
  875. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  876. // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (default) int>' to 'B<[...], char>'
  877. b2 = b3;
  878. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  879. // CHECK-ELIDE-NOTREE: no known conversion from 'B<int, char>' to 'B<char, int>'
  880. C<int> c1;
  881. C<char> c2;
  882. C<int, other> c3;
  883. c1 = c2;
  884. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  885. // CHECK-ELIDE-NOTREE: no known conversion from 'C<char, (default) I>' to 'C<int, I>'
  886. c3 = c1;
  887. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  888. // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (default) I>' to 'C<[...], other>'
  889. c2 = c3;
  890. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  891. // CHECK-ELIDE-NOTREE: no known conversion from 'C<int, other>' to 'C<char, I>'
  892. }
  893. }
  894. namespace VariadicDefault {
  895. int i1, i2, i3;
  896. template <int = 5, int...> struct A {};
  897. template <int& = i1, int& ...> struct B {};
  898. template <typename = void, typename...> struct C {};
  899. void test() {
  900. A<> a1;
  901. A<5, 6, 7> a2;
  902. A<1, 2> a3;
  903. a2 = a1;
  904. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  905. // CHECK-ELIDE-NOTREE: no known conversion from 'A<[...], (no argument), (no argument)>' to 'A<[...], 6, 7>'
  906. a3 = a1;
  907. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  908. // CHECK-ELIDE-NOTREE: no known conversion from 'A<(default) 5, (no argument)>' to 'A<1, 2>'
  909. B<> b1;
  910. B<i1, i2, i3> b2;
  911. B<i2, i3> b3;
  912. b2 = b1;
  913. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  914. // CHECK-ELIDE-NOTREE: no known conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>'
  915. b3 = b1;
  916. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  917. // CHECK-ELIDE-NOTREE: no known conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>'
  918. B<i1, i2, i3> b4 = b1;
  919. // CHECK-ELIDE-NOTREE: no viable conversion from 'B<[...], (no argument), (no argument)>' to 'B<[...], i2, i3>'
  920. B<i2, i3> b5 = b1;
  921. // CHECK-ELIDE-NOTREE: no viable conversion from 'B<(default) i1, (no argument)>' to 'B<i2, i3>'
  922. C<> c1;
  923. C<void, void> c2;
  924. C<char, char> c3;
  925. c2 = c1;
  926. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  927. // CHECK-ELIDE-NOTREE: no known conversion from 'C<[...], (no argument)>' to 'C<[...], void>'
  928. c3 = c1;
  929. // CHECK-ELIDE-NOTREE: no viable overloaded '='
  930. // CHECK-ELIDE-NOTREE: no known conversion from 'C<(default) void, (no argument)>' to 'C<char, char>'
  931. }
  932. }
  933. namespace PointerArguments {
  934. template <int *p> class T {};
  935. template <int* ...> class U {};
  936. int a, b, c;
  937. int z[5];
  938. void test() {
  939. T<&a> ta;
  940. T<z> tz;
  941. T<&b> tb(ta);
  942. // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'T<&b>'
  943. // CHECK-ELIDE-NOTREE: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'T<&a>' to 'const T<&b>' for 1st argument
  944. T<&c> tc(tz);
  945. // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'T<&c>'
  946. // CHECK-ELIDE-NOTREE: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'T<z>' to 'const T<&c>' for 1st argument
  947. U<&a, &a> uaa;
  948. U<&b> ub(uaa);
  949. // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'U<&b>'
  950. // 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
  951. U<&b, &b, &b> ubbb(uaa);
  952. // CHECK-ELIDE-NOTREE: no matching constructor for initialization of 'U<&b, &b, &b>'
  953. // 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
  954. }
  955. }
  956. namespace DependentInt {
  957. template<int Num> struct INT;
  958. template <class CLASS, class Int_wrapper = INT<CLASS::val> >
  959. struct C;
  960. struct N {
  961. static const int val = 1;
  962. };
  963. template <class M_T>
  964. struct M {};
  965. void test() {
  966. using T1 = M<C<int, INT<0>>>;
  967. using T2 = M<C<N>>;
  968. T2 p;
  969. T1 x = p;
  970. // CHECK-ELIDE-NOTREE: no viable conversion from 'M<C<DependentInt::N, INT<1>>>' to 'M<C<int, INT<0>>>'
  971. }
  972. }
  973. namespace PR17510 {
  974. class Atom;
  975. template <typename T> class allocator;
  976. template <typename T, typename A> class vector;
  977. typedef vector<const Atom *, allocator<const Atom *> > AtomVector;
  978. template <typename T, typename A = allocator<const Atom *> > class vector {};
  979. void foo() {
  980. vector<Atom *> v;
  981. AtomVector v2(v);
  982. // CHECK-ELIDE-NOTREE: no known conversion from 'vector<PR17510::Atom *, [...]>' to 'const vector<const PR17510::Atom *, [...]>'
  983. }
  984. }
  985. namespace PR15677 {
  986. template <bool>
  987. struct A{};
  988. template <typename T>
  989. using B = A<T::value>;
  990. template <typename T>
  991. using B = A<!T::value>;
  992. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<!T::value>' vs 'A<T::value>')
  993. template <int>
  994. struct C{};
  995. template <typename T>
  996. using D = C<T::value>;
  997. template <typename T>
  998. using D = C<T::value + 1>;
  999. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('C<T::value + 1>' vs 'C<T::value>')
  1000. template <typename T>
  1001. using E = C<T::value>;
  1002. template <typename T>
  1003. using E = C<42>;
  1004. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('C<42>' vs 'C<T::value>')
  1005. template <typename T>
  1006. using F = C<T::value>;
  1007. template <typename T>
  1008. using F = C<21 + 21>;
  1009. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('C<21 + 21 aka 42>' vs 'C<T::value>')
  1010. }
  1011. }
  1012. namespace AddressOf {
  1013. template <int*>
  1014. struct S {};
  1015. template <class T>
  1016. struct Wrapper {};
  1017. template <class T>
  1018. Wrapper<T> MakeWrapper();
  1019. int global, global2;
  1020. constexpr int * ptr = nullptr;
  1021. Wrapper<S<ptr>> W = MakeWrapper<S<&global>>();
  1022. // Don't print an extra '&' for 'ptr'
  1023. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<ptr>>'
  1024. // Handle parens correctly
  1025. Wrapper<S<(&global2)>> W2 = MakeWrapper<S<&global>>();
  1026. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
  1027. Wrapper<S<&global2>> W3 = MakeWrapper<S<(&global)>>();
  1028. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
  1029. Wrapper<S<(&global2)>> W4 = MakeWrapper<S<(&global)>>();
  1030. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global>>' to 'Wrapper<S<&global2>>'
  1031. }
  1032. namespace NullPtr {
  1033. template <int*, int*>
  1034. struct S {};
  1035. template <class T>
  1036. struct Wrapper {};
  1037. template <class T>
  1038. Wrapper<T> MakeWrapper();
  1039. int global, global2;
  1040. constexpr int * ptr = nullptr;
  1041. constexpr int * ptr2 = static_cast<int*>(0);
  1042. S<&global> s1 = S<&global, ptr>();
  1043. S<&global, nullptr> s2 = S<&global, ptr>();
  1044. S<&global, nullptr> s3 = S<&global, &global>();
  1045. // CHECK-ELIDE-NOTREE: no viable conversion from 'S<[...], &global>' to 'S<[...], nullptr>'
  1046. S<&global, ptr> s4 = S<&global, &global>();
  1047. // CHECK-ELIDE-NOTREE: no viable conversion from 'S<[...], &global>' to 'S<[...], ptr>
  1048. Wrapper<S<&global, nullptr>> W1 = MakeWrapper<S<&global, ptr>>();
  1049. Wrapper<S<&global, static_cast<int*>(0)>> W2 = MakeWrapper<S<&global, ptr>>();
  1050. Wrapper<S<&global, nullptr>> W3 = MakeWrapper<S<&global, &global>>();
  1051. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], nullptr>>'
  1052. Wrapper<S<&global, ptr>> W4 = MakeWrapper<S<&global, &global>>();
  1053. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], ptr>>'
  1054. Wrapper<S<&global2, ptr>> W5 = MakeWrapper<S<&global, nullptr>>();
  1055. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1056. Wrapper<S<&global2, nullptr>> W6 = MakeWrapper<S<&global, nullptr>>();
  1057. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1058. Wrapper<S<&global2, ptr2>> W7 = MakeWrapper<S<&global, nullptr>>();
  1059. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1060. Wrapper<S<&global2, nullptr>> W8 = MakeWrapper<S<&global, ptr2>>();
  1061. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1062. Wrapper<S<&global2, ptr>> W9 = MakeWrapper<S<&global, ptr2>>();
  1063. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1064. Wrapper<S<&global2, ptr2>> W10 = MakeWrapper<S<&global, ptr>>();
  1065. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1066. Wrapper<S<&global2, static_cast<int *>(0)>> W11 =
  1067. MakeWrapper<S<&global, nullptr>>();
  1068. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1069. Wrapper<S<&global2, nullptr>> W12 =
  1070. MakeWrapper<S<&global, static_cast<int *>(0)>>();
  1071. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<&global, [...]>>' to 'Wrapper<S<&global2, [...]>>'
  1072. Wrapper<S<&global, &global>> W13 = MakeWrapper<S<&global, ptr>>();
  1073. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], nullptr>>' to 'Wrapper<S<[...], &global>>'
  1074. Wrapper<S<&global, ptr>> W14 = MakeWrapper<S<&global, &global>>();
  1075. // CHECK-ELIDE-NOTREE: no viable conversion from 'Wrapper<S<[...], &global>>' to 'Wrapper<S<[...], ptr>>'
  1076. }
  1077. namespace TemplateTemplateDefault {
  1078. template <class> class A{};
  1079. template <class> class B{};
  1080. template <class> class C{};
  1081. template <template <class> class, template <class> class = A>
  1082. class T {};
  1083. T<A> t1 = T<A, C>();
  1084. // CHECK-ELIDE-NOTREE: no viable conversion from 'T<[...], template C>' to 'T<[...], (default) template A>'
  1085. T<A, C> t2 = T<A>();
  1086. // CHECK-ELIDE-NOTREE: no viable conversion from 'T<[...], (default) template A>' to 'T<[...], template C>'
  1087. T<A> t3 = T<B>();
  1088. // CHECK-ELIDE-NOTREE: no viable conversion from 'T<template B>' to 'T<template A>'
  1089. T<B, C> t4 = T<C, B>();
  1090. // CHECK-ELIDE-NOTREE: no viable conversion from 'T<template C, template B>' to 'T<template B, template C>'
  1091. T<A, A> t5 = T<B>();
  1092. // CHECK-ELIDE-NOTREE: no viable conversion from 'T<template B, [...]>' to 'T<template A, [...]>'
  1093. T<B> t6 = T<A, A>();
  1094. // CHECK-ELIDE-NOTREE: no viable conversion from 'T<template A, [...]>' to 'T<template B, [...]>'
  1095. }
  1096. namespace Bool {
  1097. template <class> class A{};
  1098. A<bool> a1 = A<int>();
  1099. // CHECK-ELIDE-NOTREE: no viable conversion from 'A<int>' to 'A<bool>'
  1100. A<int> a2 = A<bool>();
  1101. // CHECK-ELIDE-NOTREE: no viable conversion from 'A<bool>' to 'A<int>'
  1102. }
  1103. namespace TypeAlias {
  1104. template <int, int = 0> class A {};
  1105. template <class T> using a = A<T::num, 0>;
  1106. template <class T> using a = A<T::num>;
  1107. template <class T> using A1 = A<T::num>;
  1108. template <class T> using A1 = A<T::num + 0>;
  1109. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 0>' vs 'A<T::num>')
  1110. template <class T> using A2 = A<1 + T::num>;
  1111. template <class T> using A2 = A<T::num + 1>;
  1112. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<T::num + 1>' vs 'A<1 + T::num>')
  1113. template <class T> using A3 = A<(T::num)>;
  1114. template <class T> using A3 = A<T::num>;
  1115. // CHECK-ELIDE-NOTREE: error: type alias template redefinition with different types ('A<T::num>' vs 'A<(T::num)>')
  1116. template <class T> using A4 = A<(T::num)>;
  1117. template <class T> using A4 = A<((T::num))>;
  1118. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<((T::num))>' vs 'A<(T::num)>')
  1119. template <class T> using A5 = A<T::num, 1>;
  1120. template <class T> using A5 = A<T::num>;
  1121. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
  1122. template <class T> using A6 = A<T::num + 5, 1>;
  1123. template <class T> using A6 = A<T::num + 5>;
  1124. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<[...], (default) 0>' vs 'A<[...], 1>')
  1125. template <class T> using A7 = A<T::num, 1>;
  1126. template <class T> using A7 = A<(T::num)>;
  1127. // CHECK-ELIDE-NOTREE: type alias template redefinition with different types ('A<(T::num), (default) 0>' vs 'A<T::num, 1>')
  1128. }
  1129. namespace TemplateArgumentImplicitConversion {
  1130. template <int X> struct condition {};
  1131. struct is_const {
  1132. constexpr operator int() const { return 10; }
  1133. };
  1134. using T = condition<(is_const())>;
  1135. void foo(const T &t) {
  1136. T &t2 = t;
  1137. }
  1138. // CHECK-ELIDE-NOTREE: binding value of type 'const condition<[...]>' to reference to type 'condition<[...]>' drops 'const' qualifier
  1139. }
  1140. namespace BoolArgumentBitExtended {
  1141. template <bool B> struct BoolT {};
  1142. template <typename T> void foo(T) {}
  1143. void test() {
  1144. BoolT<false> X;
  1145. foo<BoolT<true>>(X);
  1146. }
  1147. // CHECK-ELIDE-NOTREE: no matching function for call to 'foo'
  1148. // CHECK-ELIDE-NOTREE: candidate function [with T = BoolArgumentBitExtended::BoolT<true>] not viable: no known conversion from 'BoolT<0>' to 'BoolT<1>' for 1st argument
  1149. }
  1150. // CHECK-ELIDE-NOTREE: {{[0-9]*}} errors generated.
  1151. // CHECK-NOELIDE-NOTREE: {{[0-9]*}} errors generated.
  1152. // CHECK-ELIDE-TREE: {{[0-9]*}} errors generated.
  1153. // CHECK-NOELIDE-TREE: {{[0-9]*}} errors generated.