warn-documentation.cpp 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393
  1. // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
  2. // This file contains lots of corner cases, so ensure that XML we generate is not invalid.
  3. // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
  4. // WRONG-NOT: CommentXMLInvalid
  5. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  6. // expected-warning@+1 {{expected quoted string after equals sign}}
  7. /// <a href=>
  8. int test_html1(int);
  9. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  10. // expected-warning@+1 {{expected quoted string after equals sign}}
  11. /// <a href==>
  12. int test_html2(int);
  13. // expected-warning@+3 {{HTML tag 'a' requires an end tag}}
  14. // expected-warning@+2 {{expected quoted string after equals sign}}
  15. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  16. /// <a href= blah
  17. int test_html3(int);
  18. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  19. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  20. /// <a =>
  21. int test_html4(int);
  22. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  23. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  24. /// <a "aaa">
  25. int test_html5(int);
  26. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  27. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  28. /// <a a="b" =>
  29. int test_html6(int);
  30. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  31. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  32. /// <a a="b" "aaa">
  33. int test_html7(int);
  34. // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
  35. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  36. /// <a a="b" =
  37. int test_html8(int);
  38. // expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
  39. /** Aaa bbb<img ddd eee
  40. * fff ggg.
  41. */
  42. int test_html9(int);
  43. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  44. /** Aaa bbb<img ddd eee 42%
  45. * fff ggg.
  46. */
  47. int test_html10(int);
  48. // expected-warning@+1 {{HTML end tag 'br' is forbidden}}
  49. /// <br></br>
  50. int test_html11(int);
  51. /// <blockquote>Meow</blockquote>
  52. int test_html_nesting1(int);
  53. /// <b><i>Meow</i></b>
  54. int test_html_nesting2(int);
  55. /// <p>Aaa<br>
  56. /// Bbb</p>
  57. int test_html_nesting3(int);
  58. /// <p>Aaa<br />
  59. /// Bbb</p>
  60. int test_html_nesting4(int);
  61. // expected-warning@+3 {{HTML tag 'b' requires an end tag}}
  62. // expected-warning@+2 {{HTML tag 'i' requires an end tag}}
  63. // expected-warning@+1 {{HTML end tag does not match any start tag}}
  64. /// <b><i>Meow</a>
  65. int test_html_nesting5(int);
  66. // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
  67. // expected-warning@+1 {{HTML end tag does not match any start tag}}
  68. /// <b><i>Meow</b></b>
  69. int test_html_nesting6(int);
  70. // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
  71. // expected-warning@+1 {{HTML end tag does not match any start tag}}
  72. /// <b><i>Meow</b></i>
  73. int test_html_nesting7(int);
  74. // expected-warning@+1 {{HTML tag 'b' requires an end tag}}
  75. /// <b>Meow
  76. int test_html_nesting8(int);
  77. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  78. /// \brief\returns Aaa
  79. int test_block_command1(int);
  80. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  81. /// \brief \returns Aaa
  82. int test_block_command2(int);
  83. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  84. /// \brief
  85. /// \returns Aaa
  86. int test_block_command3(int);
  87. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  88. /// \brief
  89. ///
  90. /// \returns Aaa
  91. int test_block_command4(int);
  92. // There is trailing whitespace on one of the following lines, don't remove it!
  93. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  94. /// \brief
  95. ///
  96. /// \returns Aaa
  97. int test_block_command5(int);
  98. /// \brief \c Aaa
  99. int test_block_command6(int);
  100. // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
  101. /// \brief Aaa
  102. ///
  103. /// Bbb
  104. ///
  105. /// \brief Ccc
  106. int test_duplicate_brief1(int);
  107. // expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
  108. /// \short Aaa
  109. ///
  110. /// Bbb
  111. ///
  112. /// \short Ccc
  113. int test_duplicate_brief2(int);
  114. // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
  115. /// \short Aaa
  116. ///
  117. /// Bbb
  118. ///
  119. /// \brief Ccc
  120. int test_duplicate_brief3(int);
  121. /// \return Aaa
  122. ///
  123. /// Bbb
  124. ///
  125. /// \return Ccc
  126. int test_multiple_returns1(int);
  127. /// \returns Aaa
  128. ///
  129. /// Bbb
  130. ///
  131. /// \returns Ccc
  132. int test_multiple_returns2(int);
  133. /// \result Aaa
  134. ///
  135. /// Bbb
  136. ///
  137. /// \result Ccc
  138. int test_multiple_returns3(int);
  139. /// \returns Aaa
  140. ///
  141. /// Bbb
  142. ///
  143. /// \return Ccc
  144. int test_multiple_returns4(int);
  145. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  146. /// \param a Blah blah.
  147. int test_param1_backslash;
  148. // rdar://13066276
  149. // Check that the diagnostic uses the same command marker as the comment.
  150. // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
  151. /// @param a Blah blah.
  152. int test_param1_at;
  153. // expected-warning@+1 {{empty paragraph passed to '\param' command}}
  154. /// \param
  155. /// \param a Blah blah.
  156. int test_param2(int a);
  157. // expected-warning@+1 {{empty paragraph passed to '\param' command}}
  158. /// \param a
  159. int test_param3(int a);
  160. /// \param a Blah blah.
  161. int test_param4(int a);
  162. /// \param [in] a Blah blah.
  163. int test_param5(int a);
  164. /// \param [out] a Blah blah.
  165. int test_param6(int a);
  166. /// \param [in,out] a Blah blah.
  167. int test_param7(int a);
  168. // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
  169. /// \param [ in ] a Blah blah.
  170. int test_param8(int a);
  171. // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
  172. /// \param [in, out] a Blah blah.
  173. int test_param9(int a);
  174. // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
  175. /// \param [ junk] a Blah blah.
  176. int test_param10(int a);
  177. // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
  178. /// \param a Blah blah.
  179. int test_param11();
  180. // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
  181. /// \param A Blah blah.
  182. int test_param12(int a);
  183. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
  184. /// \param aab Blah blah.
  185. int test_param13(int aaa, int bbb);
  186. // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
  187. /// \param aaa Blah blah.
  188. /// \param aab Blah blah.
  189. int test_param14(int aaa, int bbb);
  190. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
  191. /// \param aab Blah blah.
  192. int test_param15(int bbb, int ccc);
  193. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
  194. /// \param aab Ccc.
  195. /// \param aaa Aaa.
  196. /// \param bbb Bbb.
  197. int test_param16(int aaa, int bbb);
  198. // expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
  199. /// \param aaa Aaa.
  200. /// \param aab Ccc.
  201. /// \param bbb Bbb.
  202. int test_param17(int aaa, int bbb);
  203. // expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
  204. /// \param aaa Aaa.
  205. /// \param bbb Bbb.
  206. /// \param aab Ccc.
  207. int test_param18(int aaa, int bbb);
  208. class C {
  209. // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
  210. /// \param aaa Blah blah.
  211. C(int bbb, int ccc);
  212. // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
  213. /// \param aaa Blah blah.
  214. int test_param19(int bbb, int ccc);
  215. };
  216. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
  217. /// \param aab Blah blah.
  218. template<typename T>
  219. void test_param20(int bbb, int ccc);
  220. // expected-warning@+3 {{parameter 'a' is already documented}}
  221. // expected-note@+1 {{previous documentation}}
  222. /// \param a Aaa.
  223. /// \param a Aaa.
  224. int test_param21(int a);
  225. // expected-warning@+4 {{parameter 'x2' is already documented}}
  226. // expected-note@+2 {{previous documentation}}
  227. /// \param x1 Aaa.
  228. /// \param x2 Bbb.
  229. /// \param x2 Ccc.
  230. int test_param22(int x1, int x2, int x3);
  231. // expected-warning@+1 {{empty paragraph passed to '\param' command}}
  232. /// \param a
  233. /// \retval 0 Blah blah.
  234. int test_param23(int a);
  235. //===---
  236. // Test that we treat typedefs to some non-function types as functions for the
  237. // purposes of documentation comment parsing.
  238. //===---
  239. namespace foo {
  240. inline namespace bar {
  241. template<typename>
  242. struct function_wrapper {};
  243. template<unsigned>
  244. struct not_a_function_wrapper {};
  245. }
  246. };
  247. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  248. /// \param aaa Meow.
  249. /// \param bbb Bbb.
  250. /// \returns aaa.
  251. typedef int test_function_like_typedef1(int aaa, int ccc);
  252. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  253. /// \param aaa Meow.
  254. /// \param bbb Bbb.
  255. /// \returns aaa.
  256. typedef int (*test_function_like_typedef2)(int aaa, int ccc);
  257. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  258. /// \param aaa Meow.
  259. /// \param bbb Bbb.
  260. /// \returns aaa.
  261. typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
  262. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  263. /// \param aaa Meow.
  264. /// \param bbb Bbb.
  265. /// \returns aaa.
  266. typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
  267. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  268. /// \param aaa Meow.
  269. /// \param bbb Bbb.
  270. /// \returns aaa.
  271. typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
  272. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  273. /// \param aaa Meow.
  274. /// \param bbb Bbb.
  275. /// \returns aaa.
  276. typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
  277. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  278. /// \param aaa Meow.
  279. /// \param bbb Bbb.
  280. /// \returns aaa.
  281. typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
  282. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  283. /// \param aaa Meow.
  284. /// \param bbb Bbb.
  285. /// \returns aaa.
  286. typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
  287. typedef int (*test_not_function_like_typedef1)(int aaa);
  288. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  289. /// \param aaa Meow.
  290. typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
  291. // rdar://13066276
  292. // Check that the diagnostic uses the same command marker as the comment.
  293. // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
  294. /// @param aaa Meow.
  295. typedef unsigned int test_not_function_like_typedef3;
  296. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  297. /// \param aaa Meow.
  298. typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
  299. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  300. /// \param aaa Meow.
  301. /// \param bbb Bbb.
  302. /// \returns aaa.
  303. using test_function_like_using1 = int (int aaa, int ccc);
  304. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  305. /// \param aaa Meow.
  306. /// \param bbb Bbb.
  307. /// \returns aaa.
  308. using test_function_like_using2 = int (*)(int aaa, int ccc);
  309. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  310. /// \param aaa Meow.
  311. /// \param bbb Bbb.
  312. /// \returns aaa.
  313. using test_function_like_using3 = int (* const)(int aaa, int ccc);
  314. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  315. /// \param aaa Meow.
  316. /// \param bbb Bbb.
  317. /// \returns aaa.
  318. using test_function_like_using4 = int (C::*)(int aaa, int ccc);
  319. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  320. /// \param aaa Meow.
  321. /// \param bbb Bbb.
  322. /// \returns aaa.
  323. using test_function_like_using5 = foo::function_wrapper<int (int aaa, int ccc)>;
  324. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  325. /// \param aaa Meow.
  326. /// \param bbb Bbb.
  327. /// \returns aaa.
  328. using test_function_like_using6 = foo::function_wrapper<int (int aaa, int ccc)> *;
  329. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  330. /// \param aaa Meow.
  331. /// \param bbb Bbb.
  332. /// \returns aaa.
  333. using test_function_like_using7 = foo::function_wrapper<int (int aaa, int ccc)> &;
  334. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  335. /// \param aaa Meow.
  336. /// \param bbb Bbb.
  337. /// \returns aaa.
  338. using test_function_like_using8 = foo::function_wrapper<int (int aaa, int ccc)> &&;
  339. // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
  340. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  341. /// \param aaa Meow.
  342. /// \param bbb Bbb.
  343. /// \tparam U Uuu.
  344. template<typename T>
  345. using test_function_like_using9 = int(T aaa, int ccc);
  346. // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
  347. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  348. /// \param aaa Meow.
  349. /// \param bbb Bbb.
  350. /// \tparam U Uuu.
  351. template<typename T>
  352. using test_function_like_using10 = int (*)(T aaa, int ccc);
  353. // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
  354. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  355. /// \param aaa Meow.
  356. /// \param bbb Bbb.
  357. /// \tparam U Uuu.
  358. template<typename T>
  359. using test_function_like_using11 = foo::function_wrapper<int (T aaa, int ccc)>;
  360. // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
  361. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  362. /// \param aaa Meow.
  363. /// \param bbb Bbb.
  364. /// \tparam U Uuu.
  365. template<typename T>
  366. using test_function_like_using12 = foo::function_wrapper<int (T aaa, int ccc)> *;
  367. using test_not_function_like_using1 = int (*)(int aaa);
  368. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  369. /// \param aaa Meow.
  370. using test_not_function_like_using2 = test_not_function_like_using1;
  371. // Check that the diagnostic uses the same command marker as the comment.
  372. // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
  373. /// @param aaa Meow.
  374. using test_not_function_like_using3 = unsigned int;
  375. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  376. /// \param aaa Meow.
  377. using test_not_function_like_using4 = foo::not_a_function_wrapper<1>;
  378. /// \param aaa Aaa
  379. /// \param ... Vararg
  380. int test_vararg_param1(int aaa, ...);
  381. /// \param ... Vararg
  382. int test_vararg_param2(...);
  383. // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
  384. /// \param ... Vararg
  385. int test_vararg_param3(int aaa);
  386. // expected-warning@+1 {{parameter '...' not found in the function declaration}}
  387. /// \param ... Vararg
  388. int test_vararg_param4();
  389. /// \param aaa Aaa
  390. /// \param ... Vararg
  391. template<typename T>
  392. int test_template_vararg_param1(int aaa, ...);
  393. /// \param ... Vararg
  394. template<typename T>
  395. int test_template_vararg_param2(...);
  396. // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
  397. /// \param ... Vararg
  398. template<typename T>
  399. int test_template_vararg_param3(int aaa);
  400. // expected-warning@+1 {{parameter '...' not found in the function declaration}}
  401. /// \param ... Vararg
  402. template<typename T>
  403. int test_template_vararg_param4();
  404. // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
  405. /// \tparam T Aaa
  406. int test_tparam1;
  407. // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
  408. /// \tparam T Aaa
  409. void test_tparam2(int aaa);
  410. // expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
  411. /// \tparam
  412. /// \param aaa Blah blah
  413. template<typename T>
  414. void test_tparam3(T aaa);
  415. // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
  416. /// \tparam T Aaa
  417. template<typename TT>
  418. void test_tparam4(TT aaa);
  419. // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
  420. /// \tparam T Aaa
  421. template<typename TT>
  422. class test_tparam5 {
  423. // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
  424. /// \tparam T Aaa
  425. template<typename TTT>
  426. void test_tparam6(TTT aaa);
  427. };
  428. /// \tparam T1 Aaa
  429. /// \tparam T2 Bbb
  430. template<typename T1, typename T2>
  431. void test_tparam7(T1 aaa, T2 bbb);
  432. // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
  433. /// \tparam SomTy Aaa
  434. /// \tparam OtherTy Bbb
  435. template<typename SomeTy, typename OtherTy>
  436. void test_tparam8(SomeTy aaa, OtherTy bbb);
  437. // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
  438. /// \tparam T1 Aaa
  439. /// \tparam T1 Bbb
  440. template<typename T1, typename T2>
  441. void test_tparam9(T1 aaa, T2 bbb);
  442. /// \tparam T Aaa
  443. /// \tparam TT Bbb
  444. template<template<typename T> class TT>
  445. void test_tparam10(TT<int> aaa);
  446. /// \tparam T Aaa
  447. /// \tparam TT Bbb
  448. /// \tparam TTT Ccc
  449. template<template<template<typename T> class TT, class C> class TTT>
  450. void test_tparam11();
  451. /// \tparam I Aaa
  452. template<int I>
  453. void test_tparam12();
  454. template<typename T, typename U>
  455. class test_tparam13 { };
  456. /// \tparam T Aaa
  457. template<typename T>
  458. using test_tparam14 = test_tparam13<T, int>;
  459. // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
  460. /// \tparam U Aaa
  461. template<typename T>
  462. using test_tparam15 = test_tparam13<T, int>;
  463. // ----
  464. /// \tparam T Aaa
  465. template<typename T>
  466. class test_tparam16 { };
  467. typedef test_tparam16<int> test_tparam17;
  468. typedef test_tparam16<double> test_tparam18;
  469. // ----
  470. template<typename T>
  471. class test_tparam19;
  472. typedef test_tparam19<int> test_tparam20;
  473. typedef test_tparam19<double> test_tparam21;
  474. /// \tparam T Aaa
  475. template<typename T>
  476. class test_tparam19 { };
  477. // ----
  478. // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
  479. /// @tparam T Aaa
  480. int test_tparam22;
  481. // ----
  482. /// Aaa
  483. /// \deprecated Bbb
  484. void test_deprecated_1(int a) __attribute__((deprecated));
  485. // We don't want \deprecated to warn about empty paragraph. It is fine to use
  486. // \deprecated by itself without explanations.
  487. /// Aaa
  488. /// \deprecated
  489. void test_deprecated_2(int a) __attribute__((deprecated));
  490. /// Aaa
  491. /// \deprecated
  492. void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
  493. /// Aaa
  494. /// \deprecated
  495. void test_deprecated_4(int a) __attribute__((unavailable));
  496. // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
  497. /// Aaa
  498. /// \deprecated
  499. void test_deprecated_5(int a);
  500. // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
  501. /// Aaa
  502. /// \deprecated
  503. void test_deprecated_6(int a) {
  504. }
  505. // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
  506. /// Aaa
  507. /// \deprecated
  508. template<typename T>
  509. void test_deprecated_7(T aaa);
  510. // rdar://12397511
  511. // expected-note@+2 {{previous command '\headerfile' here}}
  512. // expected-warning@+2 {{duplicated command '\headerfile'}}
  513. /// \headerfile ""
  514. /// \headerfile foo.h
  515. int test__headerfile_1(int a);
  516. /// \invariant aaa
  517. void test_invariant_1(int a);
  518. // expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
  519. /// \invariant
  520. void test_invariant_2(int a);
  521. // no-warning
  522. /// \returns Aaa
  523. int test_returns_right_decl_1(int);
  524. class test_returns_right_decl_2 {
  525. // no-warning
  526. /// \returns Aaa
  527. int test_returns_right_decl_3(int);
  528. };
  529. // no-warning
  530. /// \returns Aaa
  531. template<typename T>
  532. int test_returns_right_decl_4(T aaa);
  533. // no-warning
  534. /// \returns Aaa
  535. template<>
  536. int test_returns_right_decl_4(int aaa);
  537. /// \returns Aaa
  538. template<typename T>
  539. T test_returns_right_decl_5(T aaa);
  540. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  541. /// \returns Aaa
  542. int test_returns_wrong_decl_1_backslash;
  543. // rdar://13066276
  544. // Check that the diagnostic uses the same command marker as the comment.
  545. // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
  546. /// @returns Aaa
  547. int test_returns_wrong_decl_1_at;
  548. // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  549. /// \return Aaa
  550. int test_returns_wrong_decl_2;
  551. // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
  552. /// \result Aaa
  553. int test_returns_wrong_decl_3;
  554. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
  555. /// \returns Aaa
  556. void test_returns_wrong_decl_4(int);
  557. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
  558. /// \returns Aaa
  559. template<typename T>
  560. void test_returns_wrong_decl_5(T aaa);
  561. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
  562. /// \returns Aaa
  563. template<>
  564. void test_returns_wrong_decl_5(int aaa);
  565. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  566. /// \returns Aaa
  567. struct test_returns_wrong_decl_6 { };
  568. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  569. /// \returns Aaa
  570. class test_returns_wrong_decl_7 {
  571. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
  572. /// \returns Aaa
  573. test_returns_wrong_decl_7();
  574. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
  575. /// \returns Aaa
  576. ~test_returns_wrong_decl_7();
  577. };
  578. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  579. /// \returns Aaa
  580. enum test_returns_wrong_decl_8 {
  581. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  582. /// \returns Aaa
  583. test_returns_wrong_decl_9
  584. };
  585. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  586. /// \returns Aaa
  587. namespace test_returns_wrong_decl_10 { };
  588. // rdar://13094352
  589. // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
  590. /*! @function test_function
  591. */
  592. typedef unsigned int Base64Flags;
  593. unsigned test_function(Base64Flags inFlags);
  594. // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
  595. /*! @callback test_callback
  596. */
  597. typedef unsigned int BaseFlags;
  598. unsigned (*test_callback)(BaseFlags inFlags);
  599. // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
  600. /// \endverbatim
  601. int test_verbatim_1();
  602. // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
  603. /// \endcode
  604. int test_verbatim_2();
  605. // FIXME: we give a bad diagnostic here because we throw away non-documentation
  606. // comments early.
  607. //
  608. // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
  609. /// \code
  610. // foo
  611. /// \endcode
  612. int test_verbatim_3();
  613. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  614. int test1; ///< \brief\author Aaa
  615. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  616. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  617. int test2, ///< \brief\author Aaa
  618. test3; ///< \brief\author Aaa
  619. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  620. int test4; ///< \brief
  621. ///< \author Aaa
  622. class TestRelates {};
  623. /// \relates TestRelates
  624. /// \brief Aaa
  625. void test_relates_1();
  626. /// \related TestRelates
  627. /// \brief Aaa
  628. void test_relates_2();
  629. /// \relatesalso TestRelates
  630. /// \brief Aaa
  631. void test_relates_3();
  632. /// \relatedalso TestRelates
  633. /// \brief Aaa
  634. void test_relates_4();
  635. // Check that we attach the comment to the declaration during parsing in the
  636. // following cases. The test is based on the fact that we don't parse
  637. // documentation comments that are not attached to anything.
  638. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  639. /// \brief\author Aaa
  640. int test_attach1;
  641. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  642. /// \brief\author Aaa
  643. int test_attach2(int);
  644. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  645. /// \brief\author Aaa
  646. struct test_attach3 {
  647. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  648. /// \brief\author Aaa
  649. int test_attach4;
  650. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  651. int test_attach5; ///< \brief\author Aaa
  652. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  653. /// \brief\author Aaa
  654. int test_attach6(int);
  655. };
  656. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  657. /// \brief\author Aaa
  658. class test_attach7 {
  659. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  660. /// \brief\author Aaa
  661. int test_attach8;
  662. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  663. int test_attach9; ///< \brief\author Aaa
  664. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  665. /// \brief\author Aaa
  666. int test_attach10(int);
  667. };
  668. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  669. /// \brief\author Aaa
  670. enum test_attach9 {
  671. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  672. /// \brief\author Aaa
  673. test_attach10,
  674. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  675. test_attach11 ///< \brief\author Aaa
  676. };
  677. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  678. /// \brief\author Aaa
  679. struct test_noattach12 *test_attach13;
  680. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  681. /// \brief\author Aaa
  682. typedef struct test_noattach14 *test_attach15;
  683. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  684. /// \brief\author Aaa
  685. typedef struct test_attach16 { int a; } test_attach17;
  686. struct S { int a; };
  687. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  688. /// \brief\author Aaa
  689. struct S *test_attach18;
  690. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  691. /// \brief\author Aaa
  692. typedef struct S *test_attach19;
  693. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  694. /// \brief\author Aaa
  695. struct test_attach20;
  696. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  697. /// \brief\author Aaa
  698. typedef struct test_attach21 {
  699. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  700. /// \brief\author Aaa
  701. int test_attach22;
  702. } test_attach23;
  703. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  704. /// \brief\author Aaa
  705. namespace test_attach24 {
  706. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  707. /// \brief\author Aaa
  708. namespace test_attach25 {
  709. }
  710. }
  711. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  712. /// \brief\author Aaa
  713. /// \tparam T Aaa
  714. template<typename T>
  715. void test_attach26(T aaa);
  716. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  717. /// \brief\author Aaa
  718. /// \tparam T Aaa
  719. template<typename T, typename U>
  720. void test_attach27(T aaa, U bbb);
  721. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  722. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  723. /// \brief\author Aaa
  724. /// \tparam T Aaa
  725. template<>
  726. void test_attach27(int aaa, int bbb);
  727. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  728. /// \brief\author Aaa
  729. /// \tparam T Aaa
  730. template<typename T>
  731. class test_attach28 {
  732. T aaa;
  733. };
  734. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  735. /// \brief\author Aaa
  736. using test_attach29 = test_attach28<int>;
  737. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  738. /// \brief\author Aaa
  739. /// \tparam T Aaa
  740. template<typename T, typename U>
  741. class test_attach30 { };
  742. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  743. /// \brief\author Aaa
  744. /// \tparam T Aaa
  745. template<typename T>
  746. class test_attach30<T, int> { };
  747. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  748. /// \brief\author Aaa
  749. template<>
  750. class test_attach30<int, int> { };
  751. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  752. /// \brief\author Aaa
  753. template<typename T>
  754. using test_attach31 = test_attach30<T, int>;
  755. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  756. /// \brief\author Aaa
  757. /// \tparam T Aaa
  758. template<typename T, typename U, typename V>
  759. class test_attach32 { };
  760. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  761. /// \brief\author Aaa
  762. /// \tparam T Aaa
  763. template<typename T, typename U>
  764. class test_attach32<T, U, int> { };
  765. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  766. /// \brief\author Aaa
  767. /// \tparam T Aaa
  768. template<typename T>
  769. class test_attach32<T, int, int> { };
  770. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  771. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  772. /// \brief\author Aaa
  773. /// \tparam T Aaa
  774. template<>
  775. class test_attach32<int, int, int> { };
  776. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  777. /// \brief\author Aaa
  778. class test_attach33 {
  779. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  780. /// \brief\author Aaa
  781. /// \tparam T Aaa
  782. template<typename T, typename U>
  783. void test_attach34(T aaa, U bbb);
  784. };
  785. template<typename T>
  786. class test_attach35 {
  787. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  788. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  789. /// \brief\author Aaa
  790. /// \tparam T Aaa
  791. template<typename TT, typename UU>
  792. void test_attach36(TT aaa, UU bbb);
  793. };
  794. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  795. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  796. /// \brief\author Aaa
  797. /// \tparam T Aaa
  798. template<> template<>
  799. void test_attach35<int>::test_attach36(int aaa, int bbb) {}
  800. template<typename T>
  801. class test_attach37 {
  802. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  803. // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
  804. /// \brief\author Aaa
  805. /// \tparam T Aaa
  806. void test_attach38(int aaa, int bbb);
  807. void test_attach39(int aaa, int bbb);
  808. };
  809. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  810. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  811. /// \brief\author Aaa
  812. /// \tparam T Aaa
  813. template<>
  814. void test_attach37<int>::test_attach38(int aaa, int bbb) {}
  815. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  816. /// \brief\author Aaa
  817. /// \tparam T Aaa
  818. template<typename T>
  819. void test_attach37<T>::test_attach39(int aaa, int bbb) {}
  820. // We used to emit warning that parameter 'a' is not found because we parsed
  821. // the comment in context of the redeclaration which does not have parameter
  822. // names.
  823. template <typename T>
  824. struct test_attach38 {
  825. /*!
  826. \param a First param
  827. \param b Second param
  828. */
  829. template <typename B>
  830. void test_attach39(T a, B b);
  831. };
  832. template <>
  833. template <typename B>
  834. void test_attach38<int>::test_attach39(int, B);
  835. // The inline comments expect a string after the command.
  836. // expected-warning@+1 {{'\a' command does not have a valid word argument}}
  837. /// \a
  838. int test_inline_no_argument_a_bad(int);
  839. /// \a A
  840. int test_inline_no_argument_a_good(int);
  841. // expected-warning@+1 {{'@b' command does not have a valid word argument}}
  842. /// @b
  843. int test_inline_no_argument_b_bad(int);
  844. /// @b A
  845. int test_inline_no_argument_b_good(int);
  846. // expected-warning@+1 {{'\c' command does not have a valid word argument}}
  847. /// \c
  848. int test_inline_no_argument_c_bad(int);
  849. /// \c A
  850. int test_inline_no_argument_c_good(int);
  851. // expected-warning@+1 {{'\e' command does not have a valid word argument}}
  852. /// \e
  853. int test_inline_no_argument_e_bad(int);
  854. /// \e A
  855. int test_inline_no_argument_e_good(int);
  856. // expected-warning@+1 {{'\em' command does not have a valid word argument}}
  857. /// \em
  858. int test_inline_no_argument_em_bad(int);
  859. /// \em A
  860. int test_inline_no_argument_em_good(int);
  861. // expected-warning@+1 {{'\p' command does not have a valid word argument}}
  862. /// \p
  863. int test_inline_no_argument_p_bad(int);
  864. /// \p A
  865. int test_inline_no_argument_p_good(int);
  866. // PR13411, reduced. We used to crash on this.
  867. /**
  868. * @code Aaa.
  869. */
  870. void test_nocrash1(int);
  871. // We used to crash on this.
  872. // expected-warning@+2 {{empty paragraph passed to '\param' command}}
  873. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  874. /// \param\brief
  875. void test_nocrash2(int);
  876. // PR13593, example 1 and 2
  877. /**
  878. * Bla.
  879. */
  880. template <typename>
  881. void test_nocrash3();
  882. /// Foo
  883. template <typename, typename>
  884. void test_nocrash4() { }
  885. template <typename>
  886. void test_nocrash3()
  887. {
  888. }
  889. // PR13593, example 3
  890. /**
  891. * aaa
  892. */
  893. template <typename T>
  894. inline T test_nocrash5(T a1)
  895. {
  896. return a1;
  897. }
  898. ///
  899. //,
  900. inline void test_nocrash6()
  901. {
  902. test_nocrash5(1);
  903. }
  904. // We used to crash on this.
  905. /*!
  906. Blah.
  907. */
  908. typedef const struct test_nocrash7 * test_nocrash8;
  909. // We used to crash on this.
  910. // expected-warning@+1 {{unknown command tag name}}
  911. /// aaa \unknown aaa \unknown aaa
  912. int test_nocrash9;
  913. // We used to crash on this. PR15068
  914. // expected-warning@+2 {{empty paragraph passed to '@param' command}}
  915. // expected-warning@+2 {{empty paragraph passed to '@param' command}}
  916. ///@param x
  917. ///@param y
  918. int test_nocrash10(int x, int y);
  919. // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
  920. // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
  921. ///@param x
  922. ///@param y
  923. int test_nocrash11();
  924. // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
  925. // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
  926. /**
  927. @param x
  928. @param y
  929. **/
  930. int test_nocrash12();
  931. // expected-warning@+2 {{empty paragraph passed to '@param' command}}
  932. // expected-warning@+1 {{empty paragraph passed to '@param' command}}
  933. ///@param x@param y
  934. int test_nocrash13(int x, int y);
  935. /**
  936. * \verbatim
  937. * Aaa
  938. **/
  939. int test_nocrash14();
  940. // rdar://12379114
  941. // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
  942. /*!
  943. @union U This is new
  944. */
  945. struct U { int iS; };
  946. /*!
  947. @union U1
  948. */
  949. union U1 {int i; };
  950. // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
  951. /*!
  952. @struct S2
  953. */
  954. union S2 {};
  955. /*!
  956. @class C1
  957. */
  958. class C1;
  959. /*!
  960. @struct S3;
  961. */
  962. class S3;
  963. // rdar://14124702
  964. //----------------------------------------------------------------------
  965. /// @class Predicate Predicate.h "lldb/Host/Predicate.h"
  966. /// @brief A C++ wrapper class for providing threaded access to a value
  967. /// of type T.
  968. ///
  969. /// A templatized class.
  970. /// specified values.
  971. //----------------------------------------------------------------------
  972. template <class T, class T1>
  973. class Predicate
  974. {
  975. };
  976. //----------------------------------------------------------------------
  977. /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
  978. /// @brief A C++ wrapper class for providing threaded access to a value
  979. /// of type T.
  980. ///
  981. /// A template specialization class.
  982. //----------------------------------------------------------------------
  983. template<> class Predicate<int, char>
  984. {
  985. };
  986. //----------------------------------------------------------------------
  987. /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
  988. /// @brief A C++ wrapper class for providing threaded access to a value
  989. /// of type T.
  990. ///
  991. /// A partial specialization template class.
  992. //----------------------------------------------------------------------
  993. template<class T> class Predicate<T, int>
  994. {
  995. };
  996. /*! @function test_function
  997. */
  998. template <class T> T test_function (T arg);
  999. /*! @function test_function<int>
  1000. */
  1001. template <> int test_function<int> (int arg);
  1002. namespace AllowParamAndReturnsOnFunctionPointerVars {
  1003. /**
  1004. * functionPointerVariable
  1005. *
  1006. * @param i is integer.
  1007. * @returns integer.
  1008. */
  1009. int (*functionPointerVariable)(int i);
  1010. struct HasFields {
  1011. /**
  1012. * functionPointerField
  1013. *
  1014. * @param i is integer.
  1015. * @returns integer.
  1016. */
  1017. int (*functionPointerField)(int i);
  1018. };
  1019. // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
  1020. /**
  1021. * functionPointerVariable
  1022. *
  1023. * \param p not here.
  1024. * \returns integer.
  1025. */
  1026. void (*functionPointerVariableThatLeadsNowhere)();
  1027. // Still warn about param/returns commands for variables that don't specify
  1028. // the type directly:
  1029. /**
  1030. * FunctionPointerTypedef
  1031. *
  1032. * \param i is integer.
  1033. * \returns integer.
  1034. */
  1035. typedef int (*FunctionPointerTypedef)(int i);
  1036. /**
  1037. * FunctionPointerTypealias
  1038. *
  1039. * \param i is integer.
  1040. * \returns integer.
  1041. */
  1042. using FunctionPointerTypealias = int (*)(int i);
  1043. // expected-warning@+5 {{'@param' command used in a comment that is not attached to a function declaration}}
  1044. // expected-warning@+5 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
  1045. /**
  1046. * functionPointerVariable
  1047. *
  1048. * @param i is integer.
  1049. * @returns integer.
  1050. */
  1051. FunctionPointerTypedef functionPointerTypedefVariable;
  1052. struct HasMoreFields {
  1053. // expected-warning@+5 {{'\param' command used in a comment that is not attached to a function declaration}}
  1054. // expected-warning@+5 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  1055. /**
  1056. * functionPointerTypealiasField
  1057. *
  1058. * \param i is integer.
  1059. * \returns integer.
  1060. */
  1061. FunctionPointerTypealias functionPointerTypealiasField;
  1062. };
  1063. }
  1064. /*!
  1065. * Function pointer typedef with variadic params.
  1066. *
  1067. * @param a
  1068. * works
  1069. *
  1070. * @param ...
  1071. * now should work too.
  1072. */
  1073. typedef void (*VariadicFnType)(int a, ...);
  1074. /*!
  1075. * Function pointer type alias with variadic params.
  1076. *
  1077. * @param a
  1078. * works
  1079. *
  1080. * @param ...
  1081. * now should work too.
  1082. */
  1083. using VariadicFnType2 = void (*)(int a, ...);
  1084. // expected-warning@+2 {{empty paragraph passed to '@note' command}}
  1085. /**
  1086. @note
  1087. \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$
  1088. \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$
  1089. */
  1090. class EmptyNoteNoCrash {
  1091. };
  1092. namespace PR42844 { // Assertion failures when using typedefed function pointers
  1093. typedef void (*AA)();
  1094. typedef AA A();
  1095. A *a; ///< \return none
  1096. // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  1097. typedef void B();
  1098. B *b; ///< \return none
  1099. // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  1100. void CC();
  1101. typedef void C();
  1102. C &c = CC; ///< \return none
  1103. // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  1104. using DD = void(*)();
  1105. using D = DD();
  1106. D *d; ///< \return none
  1107. // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  1108. using E = void();
  1109. E *e; ///< \return none
  1110. // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  1111. void FF();
  1112. using F = void();
  1113. F &f = FF; ///< \return none
  1114. // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  1115. } // namespace PR42844