warn-documentation.cpp revision c27bc80a98b9558513b50956c930eedc9e461ae0
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 253 254// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 255int test1; ///< \brief\brief Aaa 256 257// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 258// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 259int test2, ///< \brief\brief Aaa 260 test3; ///< \brief\brief Aaa 261 262// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 263int test4; ///< \brief 264 ///< \brief Aaa 265 266 267// Check that we attach the comment to the declaration during parsing in the 268// following cases. The test is based on the fact that we don't parse 269// documentation comments that are not attached to anything. 270 271// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 272/// \brief\brief Aaa 273int test_attach1; 274 275// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 276/// \brief\brief Aaa 277int test_attach2(int); 278 279// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 280/// \brief\brief Aaa 281struct test_attach3 { 282 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 283 /// \brief\brief Aaa 284 int test_attach4; 285 286 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 287 int test_attach5; ///< \brief\brief Aaa 288 289 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 290 /// \brief\brief Aaa 291 int test_attach6(int); 292}; 293 294// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 295/// \brief\brief Aaa 296class test_attach7 { 297 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 298 /// \brief\brief Aaa 299 int test_attach8; 300 301 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 302 int test_attach9; ///< \brief\brief Aaa 303 304 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 305 /// \brief\brief Aaa 306 int test_attach10(int); 307}; 308 309// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 310/// \brief\brief Aaa 311enum test_attach9 { 312 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 313 /// \brief\brief Aaa 314 test_attach10, 315 316 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 317 test_attach11 ///< \brief\brief Aaa 318}; 319 320// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 321/// \brief\brief Aaa 322struct test_noattach12 *test_attach13; 323 324// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 325/// \brief\brief Aaa 326typedef struct test_noattach14 *test_attach15; 327 328// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 329/// \brief\brief Aaa 330typedef struct test_attach16 { int a; } test_attach17; 331 332struct S { int a; }; 333 334// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 335/// \brief\brief Aaa 336struct S *test_attach18; 337 338// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 339/// \brief\brief Aaa 340typedef struct S *test_attach19; 341 342// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 343/// \brief\brief Aaa 344struct test_attach20; 345 346// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 347/// \brief\brief Aaa 348typedef struct test_attach21 { 349 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 350 /// \brief\brief Aaa 351 int test_attach22; 352} test_attach23; 353 354// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 355/// \brief\brief Aaa 356namespace test_attach24 { 357 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 358 /// \brief\brief Aaa 359 namespace test_attach25 { 360 } 361} 362 363// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 364/// \brief\brief Aaa 365/// \tparam T Aaa 366template<typename T> 367void test_attach26(T aaa); 368 369// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 370/// \brief\brief Aaa 371/// \tparam T Aaa 372template<typename T, typename U> 373void test_attach27(T aaa, U bbb); 374 375// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 376// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 377/// \brief\brief Aaa 378/// \tparam T Aaa 379template<> 380void test_attach27(int aaa, int bbb); 381 382// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 383/// \brief\brief Aaa 384/// \tparam T Aaa 385template<typename T> 386class test_attach28 { 387 T aaa; 388}; 389 390// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 391/// \brief\brief Aaa 392using test_attach29 = test_attach28<int>; 393 394// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 395/// \brief\brief Aaa 396/// \tparam T Aaa 397template<typename T, typename U> 398class test_attach30 { }; 399 400// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 401/// \brief\brief Aaa 402/// \tparam T Aaa 403template<typename T> 404class test_attach30<T, int> { }; 405 406// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 407/// \brief\brief Aaa 408template<> 409class test_attach30<int, int> { }; 410 411// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 412/// \brief\brief Aaa 413template<typename T> 414using test_attach31 = test_attach30<T, int>; 415 416// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 417/// \brief\brief Aaa 418/// \tparam T Aaa 419template<typename T, typename U, typename V> 420class test_attach32 { }; 421 422// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 423/// \brief\brief Aaa 424/// \tparam T Aaa 425template<typename T, typename U> 426class test_attach32<T, U, int> { }; 427 428// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 429/// \brief\brief Aaa 430/// \tparam T Aaa 431template<typename T> 432class test_attach32<T, int, int> { }; 433 434// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 435// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 436/// \brief\brief Aaa 437/// \tparam T Aaa 438template<> 439class test_attach32<int, int, int> { }; 440 441// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 442/// \brief\brief Aaa 443class test_attach33 { 444 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 445 /// \brief\brief Aaa 446 /// \tparam T Aaa 447 template<typename T, typename U> 448 void test_attach34(T aaa, U bbb); 449}; 450 451template<typename T> 452class test_attach35 { 453 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 454 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 455 /// \brief\brief Aaa 456 /// \tparam T Aaa 457 template<typename TT, typename UU> 458 void test_attach36(TT aaa, UU bbb); 459}; 460 461// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 462// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 463/// \brief\brief Aaa 464/// \tparam T Aaa 465template<> template<> 466void test_attach35<int>::test_attach36(int aaa, int bbb) {} 467 468template<typename T> 469class test_attach37 { 470 // expected-warning@+2 {{empty paragraph passed to '\brief' command}} 471 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}} 472 /// \brief\brief Aaa 473 /// \tparam T Aaa 474 void test_attach38(int aaa, int bbb); 475}; 476 477// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 478/// \brief\brief Aaa 479/// \tparam T Aaa 480template<typename T> 481void test_attach37<T>::test_attach38(int aaa, int bbb) {} 482 483// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 484// expected-warning@+2 {{template parameter 'T' not found in the template declaration}} 485/// \brief\brief Aaa 486/// \tparam T Aaa 487template<> 488void test_attach37<int>::test_attach38(int aaa, int bbb) {} 489 490 491// PR13411, reduced. We used to crash on this. 492/** 493 * @code Aaa. 494 */ 495void test_nocrash1(int); 496 497// We used to crash on this. 498// expected-warning@+2 {{empty paragraph passed to '\param' command}} 499// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 500/// \param\brief 501void test_nocrash2(int); 502 503