warn-documentation.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  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@+1 {{expected quoted string after equals sign}}
  6. /// <a href=>
  7. int test_html1(int);
  8. // expected-warning@+1 {{expected quoted string after equals sign}}
  9. /// <a href==>
  10. int test_html2(int);
  11. // expected-warning@+2 {{expected quoted string after equals sign}}
  12. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  13. /// <a href= blah
  14. int test_html3(int);
  15. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  16. /// <a =>
  17. int test_html4(int);
  18. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  19. /// <a "aaa">
  20. int test_html5(int);
  21. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  22. /// <a a="b" =>
  23. int test_html6(int);
  24. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  25. /// <a a="b" "aaa">
  26. int test_html7(int);
  27. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  28. /// <a a="b" =
  29. int test_html8(int);
  30. // expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
  31. /** Aaa bbb<img ddd eee
  32. * fff ggg.
  33. */
  34. int test_html9(int);
  35. // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
  36. /** Aaa bbb<img ddd eee 42%
  37. * fff ggg.
  38. */
  39. int test_html10(int);
  40. // expected-warning@+1 {{HTML end tag 'br' is forbidden}}
  41. /// <br></br>
  42. int test_html11(int);
  43. /// <blockquote>Meow</blockquote>
  44. int test_html_nesting1(int);
  45. /// <b><i>Meow</i></b>
  46. int test_html_nesting2(int);
  47. /// <p>Aaa<br>
  48. /// Bbb</p>
  49. int test_html_nesting3(int);
  50. /// <p>Aaa<br />
  51. /// Bbb</p>
  52. int test_html_nesting4(int);
  53. // expected-warning@+1 {{HTML end tag does not match any start tag}}
  54. /// <b><i>Meow</a>
  55. int test_html_nesting5(int);
  56. // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
  57. // expected-warning@+1 {{HTML end tag does not match any start tag}}
  58. /// <b><i>Meow</b></b>
  59. int test_html_nesting6(int);
  60. // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
  61. // expected-warning@+1 {{HTML end tag does not match any start tag}}
  62. /// <b><i>Meow</b></i>
  63. int test_html_nesting7(int);
  64. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  65. /// \brief\returns Aaa
  66. int test_block_command1(int);
  67. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  68. /// \brief \returns Aaa
  69. int test_block_command2(int);
  70. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  71. /// \brief
  72. /// \returns Aaa
  73. int test_block_command3(int);
  74. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  75. /// \brief
  76. ///
  77. /// \returns Aaa
  78. int test_block_command4(int);
  79. // There is trailing whitespace on one of the following lines, don't remove it!
  80. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  81. /// \brief
  82. ///
  83. /// \returns Aaa
  84. int test_block_command5(int);
  85. /// \brief \c Aaa
  86. int test_block_command6(int);
  87. // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
  88. /// \brief Aaa
  89. ///
  90. /// Bbb
  91. ///
  92. /// \brief Ccc
  93. int test_duplicate_brief1(int);
  94. // expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
  95. /// \short Aaa
  96. ///
  97. /// Bbb
  98. ///
  99. /// \short Ccc
  100. int test_duplicate_brief2(int);
  101. // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
  102. /// \short Aaa
  103. ///
  104. /// Bbb
  105. ///
  106. /// \brief Ccc
  107. int test_duplicate_brief3(int);
  108. // expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\return' here}}
  109. /// \return Aaa
  110. ///
  111. /// Bbb
  112. ///
  113. /// \return Ccc
  114. int test_duplicate_returns1(int);
  115. // expected-warning@+5 {{duplicated command '\returns'}} expected-note@+1 {{previous command '\returns' here}}
  116. /// \returns Aaa
  117. ///
  118. /// Bbb
  119. ///
  120. /// \returns Ccc
  121. int test_duplicate_returns2(int);
  122. // expected-warning@+5 {{duplicated command '\result'}} expected-note@+1 {{previous command '\result' here}}
  123. /// \result Aaa
  124. ///
  125. /// Bbb
  126. ///
  127. /// \result Ccc
  128. int test_duplicate_returns3(int);
  129. // expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\returns' (an alias of '\return') here}}
  130. /// \returns Aaa
  131. ///
  132. /// Bbb
  133. ///
  134. /// \return Ccc
  135. int test_duplicate_returns4(int);
  136. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  137. /// \param a Blah blah.
  138. int test_param1;
  139. // expected-warning@+1 {{empty paragraph passed to '\param' command}}
  140. /// \param
  141. /// \param a Blah blah.
  142. int test_param2(int a);
  143. // expected-warning@+1 {{empty paragraph passed to '\param' command}}
  144. /// \param a
  145. int test_param3(int a);
  146. /// \param a Blah blah.
  147. int test_param4(int a);
  148. /// \param [in] a Blah blah.
  149. int test_param5(int a);
  150. /// \param [out] a Blah blah.
  151. int test_param6(int a);
  152. /// \param [in,out] a Blah blah.
  153. int test_param7(int a);
  154. // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
  155. /// \param [ in ] a Blah blah.
  156. int test_param8(int a);
  157. // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
  158. /// \param [in, out] a Blah blah.
  159. int test_param9(int a);
  160. // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
  161. /// \param [ junk] a Blah blah.
  162. int test_param10(int a);
  163. // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
  164. /// \param a Blah blah.
  165. int test_param11();
  166. // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
  167. /// \param A Blah blah.
  168. int test_param12(int a);
  169. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
  170. /// \param aab Blah blah.
  171. int test_param13(int aaa, int bbb);
  172. // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
  173. /// \param aaa Blah blah.
  174. /// \param aab Blah blah.
  175. int test_param14(int aaa, int bbb);
  176. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
  177. /// \param aab Blah blah.
  178. int test_param15(int bbb, int ccc);
  179. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
  180. /// \param aab Ccc.
  181. /// \param aaa Aaa.
  182. /// \param bbb Bbb.
  183. int test_param16(int aaa, int bbb);
  184. // expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
  185. /// \param aaa Aaa.
  186. /// \param aab Ccc.
  187. /// \param bbb Bbb.
  188. int test_param17(int aaa, int bbb);
  189. // expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
  190. /// \param aaa Aaa.
  191. /// \param bbb Bbb.
  192. /// \param aab Ccc.
  193. int test_param18(int aaa, int bbb);
  194. class C {
  195. // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
  196. /// \param aaa Blah blah.
  197. C(int bbb, int ccc);
  198. // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
  199. /// \param aaa Blah blah.
  200. int test_param19(int bbb, int ccc);
  201. };
  202. // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
  203. /// \param aab Blah blah.
  204. template<typename T>
  205. void test_param20(int bbb, int ccc);
  206. // expected-warning@+3 {{parameter 'a' is already documented}}
  207. // expected-note@+1 {{previous documentation}}
  208. /// \param a Aaa.
  209. /// \param a Aaa.
  210. int test_param21(int a);
  211. // expected-warning@+4 {{parameter 'x2' is already documented}}
  212. // expected-note@+2 {{previous documentation}}
  213. /// \param x1 Aaa.
  214. /// \param x2 Bbb.
  215. /// \param x2 Ccc.
  216. int test_param22(int x1, int x2, int x3);
  217. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  218. /// \param aaa Meow.
  219. /// \param bbb Bbb.
  220. /// \returns aaa.
  221. typedef int test_param23(int aaa, int ccc);
  222. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  223. /// \param aaa Meow.
  224. /// \param bbb Bbb.
  225. /// \returns aaa.
  226. typedef int (*test_param24)(int aaa, int ccc);
  227. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  228. /// \param aaa Meow.
  229. /// \param bbb Bbb.
  230. /// \returns aaa.
  231. typedef int (* const test_param25)(int aaa, int ccc);
  232. // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
  233. /// \param aaa Meow.
  234. /// \param bbb Bbb.
  235. /// \returns aaa.
  236. typedef int (C::*test_param26)(int aaa, int ccc);
  237. typedef int (*test_param27)(int aaa);
  238. // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
  239. /// \param aaa Meow.
  240. typedef test_param27 test_param28;
  241. // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
  242. /// \tparam T Aaa
  243. int test_tparam1;
  244. // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
  245. /// \tparam T Aaa
  246. void test_tparam2(int aaa);
  247. // expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
  248. /// \tparam
  249. /// \param aaa Blah blah
  250. template<typename T>
  251. void test_tparam3(T aaa);
  252. // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
  253. /// \tparam T Aaa
  254. template<typename TT>
  255. void test_tparam4(TT aaa);
  256. // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
  257. /// \tparam T Aaa
  258. template<typename TT>
  259. class test_tparam5 {
  260. // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
  261. /// \tparam T Aaa
  262. template<typename TTT>
  263. void test_tparam6(TTT aaa);
  264. };
  265. /// \tparam T1 Aaa
  266. /// \tparam T2 Bbb
  267. template<typename T1, typename T2>
  268. void test_tparam7(T1 aaa, T2 bbb);
  269. // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
  270. /// \tparam SomTy Aaa
  271. /// \tparam OtherTy Bbb
  272. template<typename SomeTy, typename OtherTy>
  273. void test_tparam8(SomeTy aaa, OtherTy bbb);
  274. // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
  275. /// \tparam T1 Aaa
  276. /// \tparam T1 Bbb
  277. template<typename T1, typename T2>
  278. void test_tparam9(T1 aaa, T2 bbb);
  279. /// \tparam T Aaa
  280. /// \tparam TT Bbb
  281. template<template<typename T> class TT>
  282. void test_tparam10(TT<int> aaa);
  283. /// \tparam T Aaa
  284. /// \tparam TT Bbb
  285. /// \tparam TTT Ccc
  286. template<template<template<typename T> class TT, class C> class TTT>
  287. void test_tparam11();
  288. /// \tparam I Aaa
  289. template<int I>
  290. void test_tparam12();
  291. template<typename T, typename U>
  292. class test_tparam13 { };
  293. /// \tparam T Aaa
  294. template<typename T>
  295. using test_tparam14 = test_tparam13<T, int>;
  296. // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
  297. /// \tparam U Aaa
  298. template<typename T>
  299. using test_tparam15 = test_tparam13<T, int>;
  300. // ----
  301. /// \tparam T Aaa
  302. template<typename T>
  303. class test_tparam16 { };
  304. typedef test_tparam16<int> test_tparam17;
  305. typedef test_tparam16<double> test_tparam18;
  306. // ----
  307. template<typename T>
  308. class test_tparam19;
  309. typedef test_tparam19<int> test_tparam20;
  310. typedef test_tparam19<double> test_tparam21;
  311. /// \tparam T Aaa
  312. template<typename T>
  313. class test_tparam19 { };
  314. // ----
  315. /// Aaa
  316. /// \deprecated Bbb
  317. void test_deprecated_1(int a) __attribute__((deprecated));
  318. // We don't want \deprecated to warn about empty paragraph. It is fine to use
  319. // \deprecated by itself without explanations.
  320. /// Aaa
  321. /// \deprecated
  322. void test_deprecated_2(int a) __attribute__((deprecated));
  323. /// Aaa
  324. /// \deprecated
  325. void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
  326. /// Aaa
  327. /// \deprecated
  328. void test_deprecated_4(int a) __attribute__((unavailable));
  329. // 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}}
  330. /// Aaa
  331. /// \deprecated
  332. void test_deprecated_5(int a);
  333. // 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}}
  334. /// Aaa
  335. /// \deprecated
  336. void test_deprecated_6(int a) {
  337. }
  338. // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
  339. /// Aaa
  340. /// \deprecated
  341. template<typename T>
  342. void test_deprecated_7(T aaa);
  343. /// \invariant aaa
  344. void test_invariant_1(int a);
  345. // expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
  346. /// \invariant
  347. void test_invariant_2(int a);
  348. // no-warning
  349. /// \returns Aaa
  350. int test_returns_right_decl_1(int);
  351. class test_returns_right_decl_2 {
  352. // no-warning
  353. /// \returns Aaa
  354. int test_returns_right_decl_3(int);
  355. };
  356. // no-warning
  357. /// \returns Aaa
  358. template<typename T>
  359. int test_returns_right_decl_4(T aaa);
  360. // no-warning
  361. /// \returns Aaa
  362. template<>
  363. int test_returns_right_decl_4(int aaa);
  364. /// \returns Aaa
  365. template<typename T>
  366. T test_returns_right_decl_5(T aaa);
  367. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  368. /// \returns Aaa
  369. int test_returns_wrong_decl_1;
  370. // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  371. /// \return Aaa
  372. int test_returns_wrong_decl_2;
  373. // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
  374. /// \result Aaa
  375. int test_returns_wrong_decl_3;
  376. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
  377. /// \returns Aaa
  378. void test_returns_wrong_decl_4(int);
  379. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
  380. /// \returns Aaa
  381. template<typename T>
  382. void test_returns_wrong_decl_5(T aaa);
  383. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
  384. /// \returns Aaa
  385. template<>
  386. void test_returns_wrong_decl_5(int aaa);
  387. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  388. /// \returns Aaa
  389. struct test_returns_wrong_decl_6 { };
  390. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  391. /// \returns Aaa
  392. class test_returns_wrong_decl_7 {
  393. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
  394. /// \returns Aaa
  395. test_returns_wrong_decl_7();
  396. // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
  397. /// \returns Aaa
  398. ~test_returns_wrong_decl_7();
  399. };
  400. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  401. /// \returns Aaa
  402. enum test_returns_wrong_decl_8 {
  403. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  404. /// \returns Aaa
  405. test_returns_wrong_decl_9
  406. };
  407. // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
  408. /// \returns Aaa
  409. namespace test_returns_wrong_decl_10 { };
  410. // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
  411. /// \endverbatim
  412. int test_verbatim_1();
  413. // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
  414. /// \endcode
  415. int test_verbatim_2();
  416. // FIXME: we give a bad diagnostic here because we throw away non-documentation
  417. // comments early.
  418. //
  419. // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
  420. /// \code
  421. // foo
  422. /// \endcode
  423. int test_verbatim_3();
  424. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  425. int test1; ///< \brief\author Aaa
  426. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  427. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  428. int test2, ///< \brief\author Aaa
  429. test3; ///< \brief\author Aaa
  430. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  431. int test4; ///< \brief
  432. ///< \author Aaa
  433. // Check that we attach the comment to the declaration during parsing in the
  434. // following cases. The test is based on the fact that we don't parse
  435. // documentation comments that are not attached to anything.
  436. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  437. /// \brief\author Aaa
  438. int test_attach1;
  439. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  440. /// \brief\author Aaa
  441. int test_attach2(int);
  442. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  443. /// \brief\author Aaa
  444. struct test_attach3 {
  445. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  446. /// \brief\author Aaa
  447. int test_attach4;
  448. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  449. int test_attach5; ///< \brief\author Aaa
  450. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  451. /// \brief\author Aaa
  452. int test_attach6(int);
  453. };
  454. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  455. /// \brief\author Aaa
  456. class test_attach7 {
  457. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  458. /// \brief\author Aaa
  459. int test_attach8;
  460. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  461. int test_attach9; ///< \brief\author Aaa
  462. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  463. /// \brief\author Aaa
  464. int test_attach10(int);
  465. };
  466. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  467. /// \brief\author Aaa
  468. enum test_attach9 {
  469. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  470. /// \brief\author Aaa
  471. test_attach10,
  472. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  473. test_attach11 ///< \brief\author Aaa
  474. };
  475. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  476. /// \brief\author Aaa
  477. struct test_noattach12 *test_attach13;
  478. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  479. /// \brief\author Aaa
  480. typedef struct test_noattach14 *test_attach15;
  481. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  482. /// \brief\author Aaa
  483. typedef struct test_attach16 { int a; } test_attach17;
  484. struct S { int a; };
  485. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  486. /// \brief\author Aaa
  487. struct S *test_attach18;
  488. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  489. /// \brief\author Aaa
  490. typedef struct S *test_attach19;
  491. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  492. /// \brief\author Aaa
  493. struct test_attach20;
  494. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  495. /// \brief\author Aaa
  496. typedef struct test_attach21 {
  497. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  498. /// \brief\author Aaa
  499. int test_attach22;
  500. } test_attach23;
  501. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  502. /// \brief\author Aaa
  503. namespace test_attach24 {
  504. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  505. /// \brief\author Aaa
  506. namespace test_attach25 {
  507. }
  508. }
  509. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  510. /// \brief\author Aaa
  511. /// \tparam T Aaa
  512. template<typename T>
  513. void test_attach26(T aaa);
  514. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  515. /// \brief\author Aaa
  516. /// \tparam T Aaa
  517. template<typename T, typename U>
  518. void test_attach27(T aaa, U bbb);
  519. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  520. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  521. /// \brief\author Aaa
  522. /// \tparam T Aaa
  523. template<>
  524. void test_attach27(int aaa, int bbb);
  525. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  526. /// \brief\author Aaa
  527. /// \tparam T Aaa
  528. template<typename T>
  529. class test_attach28 {
  530. T aaa;
  531. };
  532. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  533. /// \brief\author Aaa
  534. using test_attach29 = test_attach28<int>;
  535. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  536. /// \brief\author Aaa
  537. /// \tparam T Aaa
  538. template<typename T, typename U>
  539. class test_attach30 { };
  540. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  541. /// \brief\author Aaa
  542. /// \tparam T Aaa
  543. template<typename T>
  544. class test_attach30<T, int> { };
  545. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  546. /// \brief\author Aaa
  547. template<>
  548. class test_attach30<int, int> { };
  549. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  550. /// \brief\author Aaa
  551. template<typename T>
  552. using test_attach31 = test_attach30<T, int>;
  553. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  554. /// \brief\author Aaa
  555. /// \tparam T Aaa
  556. template<typename T, typename U, typename V>
  557. class test_attach32 { };
  558. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  559. /// \brief\author Aaa
  560. /// \tparam T Aaa
  561. template<typename T, typename U>
  562. class test_attach32<T, U, int> { };
  563. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  564. /// \brief\author Aaa
  565. /// \tparam T Aaa
  566. template<typename T>
  567. class test_attach32<T, int, int> { };
  568. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  569. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  570. /// \brief\author Aaa
  571. /// \tparam T Aaa
  572. template<>
  573. class test_attach32<int, int, int> { };
  574. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  575. /// \brief\author Aaa
  576. class test_attach33 {
  577. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  578. /// \brief\author Aaa
  579. /// \tparam T Aaa
  580. template<typename T, typename U>
  581. void test_attach34(T aaa, U bbb);
  582. };
  583. template<typename T>
  584. class test_attach35 {
  585. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  586. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  587. /// \brief\author Aaa
  588. /// \tparam T Aaa
  589. template<typename TT, typename UU>
  590. void test_attach36(TT aaa, UU bbb);
  591. };
  592. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  593. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  594. /// \brief\author Aaa
  595. /// \tparam T Aaa
  596. template<> template<>
  597. void test_attach35<int>::test_attach36(int aaa, int bbb) {}
  598. template<typename T>
  599. class test_attach37 {
  600. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  601. // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
  602. /// \brief\author Aaa
  603. /// \tparam T Aaa
  604. void test_attach38(int aaa, int bbb);
  605. void test_attach39(int aaa, int bbb);
  606. };
  607. // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
  608. // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
  609. /// \brief\author Aaa
  610. /// \tparam T Aaa
  611. template<>
  612. void test_attach37<int>::test_attach38(int aaa, int bbb) {}
  613. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  614. /// \brief\author Aaa
  615. /// \tparam T Aaa
  616. template<typename T>
  617. void test_attach37<T>::test_attach39(int aaa, int bbb) {}
  618. // We used to emit warning that parameter 'a' is not found because we parsed
  619. // the comment in context of the redeclaration which does not have parameter
  620. // names.
  621. template <typename T>
  622. struct test_attach38 {
  623. /*!
  624. \param a First param
  625. \param b Second param
  626. */
  627. template <typename B>
  628. void test_attach39(T a, B b);
  629. };
  630. template <>
  631. template <typename B>
  632. void test_attach38<int>::test_attach39(int, B);
  633. // PR13411, reduced. We used to crash on this.
  634. /**
  635. * @code Aaa.
  636. */
  637. void test_nocrash1(int);
  638. // We used to crash on this.
  639. // expected-warning@+2 {{empty paragraph passed to '\param' command}}
  640. // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
  641. /// \param\brief
  642. void test_nocrash2(int);
  643. // PR13593, example 1 and 2
  644. /**
  645. * Bla.
  646. */
  647. template <typename>
  648. void test_nocrash3();
  649. /// Foo
  650. template <typename, typename>
  651. void test_nocrash4() { }
  652. template <typename>
  653. void test_nocrash3()
  654. {
  655. }
  656. // PR13593, example 3
  657. /**
  658. * aaa
  659. */
  660. template <typename T>
  661. inline T test_nocrash5(T a1)
  662. {
  663. return a1;
  664. }
  665. ///
  666. //,
  667. inline void test_nocrash6()
  668. {
  669. test_nocrash5(1);
  670. }
  671. // We used to crash on this.
  672. /*!
  673. Blah.
  674. */
  675. typedef const struct test_nocrash7 * test_nocrash8;
  676. // We used to crash on this.
  677. /// aaa \unknown aaa \unknown aaa
  678. int test_nocrash9;
  679. // We used to crash on this. PR15068
  680. // expected-warning@+2 {{empty paragraph passed to '@param' command}}
  681. // expected-warning@+2 {{empty paragraph passed to '@param' command}}
  682. ///@param x
  683. ///@param y
  684. int test_nocrash10(int x, int y);
  685. // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
  686. // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
  687. ///@param x
  688. ///@param y
  689. int test_nocrash11();
  690. // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
  691. // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
  692. /**
  693. @param x
  694. @param y
  695. **/
  696. int test_nocrash12();
  697. // expected-warning@+2 {{empty paragraph passed to '@param' command}}
  698. // expected-warning@+1 {{empty paragraph passed to '@param' command}}
  699. ///@param x@param y
  700. int test_nocrash13(int x, int y);
  701. // rdar://12397511
  702. // expected-note@+2 {{previous command '\headerfile' here}}
  703. // expected-warning@+2 {{duplicated command '\headerfile'}}
  704. /// \headerfile ""
  705. /// \headerfile foo.h
  706. int test_duplicate_headerfile1(int);
  707. // rdar://13066276
  708. // expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
  709. /** @return s */
  710. struct s* f(void);
  711. struct s;
  712. // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
  713. /** \return s */
  714. struct q* g(void);
  715. struct q;