warn-documentation.cpp revision 967e5d7ebb775a93f9c200d19d557d18bf945f10
1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s 2 3// expected-warning@+1 {{expected quoted string after equals sign}} 4/// <a href=> 5int test_html1(int); 6 7// expected-warning@+1 {{expected quoted string after equals sign}} 8/// <a href==> 9int test_html2(int); 10 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 14int test_html3(int); 15 16// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 17/// <a => 18int test_html4(int); 19 20// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 21/// <a "aaa"> 22int test_html5(int); 23 24// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 25/// <a a="b" => 26int test_html6(int); 27 28// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 29/// <a a="b" "aaa"> 30int test_html7(int); 31 32// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 33/// <a a="b" = 34int test_html8(int); 35 36// expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}} 37/** Aaa bbb<ccc ddd eee 38 * fff ggg. 39 */ 40int test_html9(int); 41 42// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}} 43/** Aaa bbb<ccc ddd eee 42% 44 * fff ggg. 45 */ 46int test_html10(int); 47 48// expected-warning@+1 {{HTML end tag 'br' is forbidden}} 49/// <br></br> 50int test_html11(int); 51 52/// <blockquote>Meow</blockquote> 53int test_html_nesting1(int); 54 55/// <b><i>Meow</i></b> 56int test_html_nesting2(int); 57 58/// <p>Aaa<br> 59/// Bbb</p> 60int test_html_nesting3(int); 61 62/// <p>Aaa<br /> 63/// Bbb</p> 64int test_html_nesting4(int); 65 66// expected-warning@+1 {{HTML end tag does not match any start tag}} 67/// <b><i>Meow</a> 68int test_html_nesting5(int); 69 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></b> 73int test_html_nesting6(int); 74 75// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}} 76// expected-warning@+1 {{HTML end tag does not match any start tag}} 77/// <b><i>Meow</b></i> 78int test_html_nesting7(int); 79 80 81// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 82/// \brief\brief Aaa 83int test_block_command1(int); 84 85// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 86/// \brief \brief Aaa 87int test_block_command2(int); 88 89// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 90/// \brief 91/// \brief Aaa 92int test_block_command3(int); 93 94// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 95/// \brief 96/// 97/// \brief Aaa 98int test_block_command4(int); 99 100// There is trailing whitespace on one of the following lines, don't remove it! 101// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 102/// \brief 103/// 104/// \brief Aaa 105int test_block_command5(int); 106 107/// \brief \c Aaa 108int test_block_command6(int); 109 110// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}} 111/// \param a Blah blah. 112int test_param1; 113 114// expected-warning@+1 {{empty paragraph passed to '\param' command}} 115/// \param 116/// \param a Blah blah. 117int test_param2(int a); 118 119// expected-warning@+1 {{empty paragraph passed to '\param' command}} 120/// \param a 121int test_param3(int a); 122 123/// \param a Blah blah. 124int test_param4(int a); 125 126/// \param [in] a Blah blah. 127int test_param5(int a); 128 129/// \param [out] a Blah blah. 130int test_param6(int a); 131 132/// \param [in,out] a Blah blah. 133int test_param7(int a); 134 135// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}} 136/// \param [ in ] a Blah blah. 137int test_param8(int a); 138 139// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}} 140/// \param [in, out] a Blah blah. 141int test_param9(int a); 142 143// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}} 144/// \param [ junk] a Blah blah. 145int test_param10(int a); 146 147// expected-warning@+1 {{parameter 'a' not found in the function declaration}} 148/// \param a Blah blah. 149int test_param11(); 150 151// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}} 152/// \param A Blah blah. 153int test_param12(int a); 154 155// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 156/// \param aab Blah blah. 157int test_param13(int aaa, int bbb); 158 159// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} 160/// \param aab Blah blah. 161int test_param14(int bbb, int ccc); 162 163class C { 164 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} 165 /// \param aaa Blah blah. 166 C(int bbb, int ccc); 167 168 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} 169 /// \param aaa Blah blah. 170 int test_param15(int bbb, int ccc); 171}; 172 173// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} 174/// \param aab Blah blah. 175template<typename T> 176void test_param16(int bbb, int ccc); 177 178// expected-warning@+3 {{parameter 'a' is already documented}} 179// expected-note@+1 {{previous documentation}} 180/// \param a Aaa. 181/// \param a Aaa. 182int test_param17(int a); 183 184// expected-warning@+4 {{parameter 'x2' is already documented}} 185// expected-note@+2 {{previous documentation}} 186/// \param x1 Aaa. 187/// \param x2 Bbb. 188/// \param x2 Ccc. 189int test_param18(int x1, int x2, int x3); 190 191 192// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} 193/// \tparam T Aaa 194int test_tparam1; 195 196// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}} 197/// \tparam T Aaa 198void test_tparam2(int aaa); 199 200// expected-warning@+1 {{empty paragraph passed to '\tparam' command}} 201/// \tparam 202/// \param aaa Blah blah 203template<typename T> 204void test_tparam3(T aaa); 205 206// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} 207/// \tparam T Aaa 208template<typename TT> 209void test_tparam4(TT aaa); 210 211// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}} 212/// \tparam T Aaa 213template<typename TT> 214class test_tparam5 { 215 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}} 216 /// \tparam T Aaa 217 template<typename TTT> 218 void test_tparam6(TTT aaa); 219}; 220 221/// \tparam T1 Aaa 222/// \tparam T2 Bbb 223template<typename T1, typename T2> 224void test_tparam7(T1 aaa, T2 bbb); 225 226// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}} 227/// \tparam SomTy Aaa 228/// \tparam OtherTy Bbb 229template<typename SomeTy, typename OtherTy> 230void test_tparam8(SomeTy aaa, OtherTy bbb); 231 232// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}} 233/// \tparam T1 Aaa 234/// \tparam T1 Bbb 235template<typename T1, typename T2> 236void test_tparam9(T1 aaa, T2 bbb); 237 238/// \tparam T Aaa 239/// \tparam TT Bbb 240template<template<typename T> class TT> 241void test_tparam10(TT<int> aaa); 242 243/// \tparam T Aaa 244/// \tparam TT Bbb 245/// \tparam TTT Ccc 246template<template<template<typename T> class TT, class C> class TTT> 247void test_tparam11(); 248 249/// \tparam I Aaa 250template<int I> 251void test_tparam12(); 252 253template<typename T, typename U> 254class test_tparam13 { }; 255 256/// \tparam T Aaa 257template<typename T> 258using test_tparam14 = test_tparam13<T, int>; 259 260// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}} 261/// \tparam U Aaa 262template<typename T> 263using test_tparam15 = test_tparam13<T, int>; 264 265 266// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 267int test1; ///< \brief\brief Aaa 268 269// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 270// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 271int test2, ///< \brief\brief Aaa 272 test3; ///< \brief\brief Aaa 273 274// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 275int test4; ///< \brief 276 ///< \brief Aaa 277 278 279// Check that we attach the comment to the declaration during parsing in the 280// following cases. The test is based on the fact that we don't parse 281// documentation comments that are not attached to anything. 282 283// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 284/// \brief\brief Aaa 285int test_attach1; 286 287// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 288/// \brief\brief Aaa 289int test_attach2(int); 290 291// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 292/// \brief\brief Aaa 293struct test_attach3 { 294 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 295 /// \brief\brief Aaa 296 int test_attach4; 297 298 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 299 int test_attach5; ///< \brief\brief Aaa 300 301 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 302 /// \brief\brief Aaa 303 int test_attach6(int); 304}; 305 306// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 307/// \brief\brief Aaa 308class test_attach7 { 309 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 310 /// \brief\brief Aaa 311 int test_attach8; 312 313 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 314 int test_attach9; ///< \brief\brief Aaa 315 316 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 317 /// \brief\brief Aaa 318 int test_attach10(int); 319}; 320 321// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 322/// \brief\brief Aaa 323enum test_attach9 { 324 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 325 /// \brief\brief Aaa 326 test_attach10, 327 328 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 329 test_attach11 ///< \brief\brief Aaa 330}; 331 332// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 333/// \brief\brief Aaa 334struct test_noattach12 *test_attach13; 335 336// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 337/// \brief\brief Aaa 338typedef struct test_noattach14 *test_attach15; 339 340// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 341/// \brief\brief Aaa 342typedef struct test_attach16 { int a; } test_attach17; 343 344struct S { int a; }; 345 346// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 347/// \brief\brief Aaa 348struct S *test_attach18; 349 350// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 351/// \brief\brief Aaa 352typedef struct S *test_attach19; 353 354// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 355/// \brief\brief Aaa 356struct test_attach20; 357 358// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 359/// \brief\brief Aaa 360typedef struct test_attach21 { 361 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 362 /// \brief\brief Aaa 363 int test_attach22; 364} test_attach23; 365 366// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 367/// \brief\brief Aaa 368namespace test_attach24 { 369 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 370 /// \brief\brief Aaa 371 namespace test_attach25 { 372 } 373} 374 375// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 376/// \brief\brief Aaa 377/// \tparam T Aaa 378template<typename T> 379void test_attach26(T aaa); 380 381// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 382/// \brief\brief Aaa 383/// \tparam T Aaa 384template<typename T, typename U> 385void test_attach27(T aaa, U bbb); 386 387// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 388// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 389/// \brief\brief Aaa 390/// \tparam T Aaa 391template<> 392void test_attach27(int aaa, int bbb); 393 394// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 395/// \brief\brief Aaa 396/// \tparam T Aaa 397template<typename T> 398class test_attach28 { 399 T aaa; 400}; 401 402// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 403/// \brief\brief Aaa 404using test_attach29 = test_attach28<int>; 405 406// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 407/// \brief\brief Aaa 408/// \tparam T Aaa 409template<typename T, typename U> 410class test_attach30 { }; 411 412// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 413/// \brief\brief Aaa 414/// \tparam T Aaa 415template<typename T> 416class test_attach30<T, int> { }; 417 418// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 419/// \brief\brief Aaa 420template<> 421class test_attach30<int, int> { }; 422 423// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 424/// \brief\brief Aaa 425template<typename T> 426using test_attach31 = test_attach30<T, int>; 427 428// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 429/// \brief\brief Aaa 430/// \tparam T Aaa 431template<typename T, typename U, typename V> 432class test_attach32 { }; 433 434// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 435/// \brief\brief Aaa 436/// \tparam T Aaa 437template<typename T, typename U> 438class test_attach32<T, U, int> { }; 439 440// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 441/// \brief\brief Aaa 442/// \tparam T Aaa 443template<typename T> 444class test_attach32<T, int, int> { }; 445 446// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 447// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 448/// \brief\brief Aaa 449/// \tparam T Aaa 450template<> 451class test_attach32<int, int, int> { }; 452 453// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 454/// \brief\brief Aaa 455class test_attach33 { 456 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 457 /// \brief\brief Aaa 458 /// \tparam T Aaa 459 template<typename T, typename U> 460 void test_attach34(T aaa, U bbb); 461}; 462 463template<typename T> 464class test_attach35 { 465 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 466 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 467 /// \brief\brief Aaa 468 /// \tparam T Aaa 469 template<typename TT, typename UU> 470 void test_attach36(TT aaa, UU bbb); 471}; 472 473// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 474// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 475/// \brief\brief Aaa 476/// \tparam T Aaa 477template<> template<> 478void test_attach35<int>::test_attach36(int aaa, int bbb) {} 479 480template<typename T> 481class test_attach37 { 482 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 483 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}} 484 /// \brief\brief Aaa 485 /// \tparam T Aaa 486 void test_attach38(int aaa, int bbb); 487}; 488 489// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 490/// \brief\brief Aaa 491/// \tparam T Aaa 492template<typename T> 493void test_attach37<T>::test_attach38(int aaa, int bbb) {} 494 495// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 496// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 497/// \brief\brief Aaa 498/// \tparam T Aaa 499template<> 500void test_attach37<int>::test_attach38(int aaa, int bbb) {} 501 502 503// PR13411, reduced. We used to crash on this. 504/** 505 * @code Aaa. 506 */ 507void test_nocrash1(int); 508 509// We used to crash on this. 510// expected-warning@+2 {{empty paragraph passed to '\param' command}} 511// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 512/// \param\brief 513void test_nocrash2(int); 514 515