warn-documentation.cpp revision 6582277bfc8bb587602e2c0689b6b2ff4b9bef53
1// RUN: %clang_cc1 -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}} expected-note@+1 {{did you mean 'a'?}} 148/// \param A Blah blah. 149int test_param11(int a); 150 151// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}} 152/// \param aab Blah blah. 153int test_param12(int aaa, int bbb); 154 155// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} 156/// \param aab Blah blah. 157int test_param13(int bbb, int ccc); 158 159class C { 160 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} 161 /// \param aaa Blah blah. 162 C(int bbb, int ccc); 163 164 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}} 165 /// \param aaa Blah blah. 166 int test_param14(int bbb, int ccc); 167}; 168 169// expected-warning@+3 {{parameter 'a' is already documented}} 170// expected-note@+1 {{previous documentation}} 171/// \param a Aaa. 172/// \param a Aaa. 173int test_param15(int a); 174 175// expected-warning@+4 {{parameter 'x2' is already documented}} 176// expected-note@+2 {{previous documentation}} 177/// \param x1 Aaa. 178/// \param x2 Bbb. 179/// \param x2 Ccc. 180int test_param16(int x1, int x2, int x3); 181 182// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 183int test1; ///< \brief\brief Aaa 184 185// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 186// expected-warning@+2 {{empty paragraph passed to '\brief' command}} 187int test2, ///< \brief\brief Aaa 188 test3; ///< \brief\brief Aaa 189 190// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 191int test4; ///< \brief 192 ///< \brief Aaa 193 194 195// Check that we attach the comment to the declaration during parsing in the 196// following cases. The test is based on the fact that we don't parse 197// documentation comments that are not attached to anything. 198 199// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 200/// \brief\brief Aaa 201int test_attach1; 202 203// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 204/// \brief\brief Aaa 205int test_attach2(int); 206 207// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 208/// \brief\brief Aaa 209struct test_attach3 { 210 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 211 /// \brief\brief Aaa 212 int test_attach4; 213 214 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 215 int test_attach5; ///< \brief\brief Aaa 216 217 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 218 /// \brief\brief Aaa 219 int test_attach6(int); 220}; 221 222// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 223/// \brief\brief Aaa 224class test_attach7 { 225 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 226 /// \brief\brief Aaa 227 int test_attach8; 228 229 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 230 int test_attach9; ///< \brief\brief Aaa 231 232 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 233 /// \brief\brief Aaa 234 int test_attach10(int); 235}; 236 237// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 238/// \brief\brief Aaa 239enum test_attach9 { 240 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 241 /// \brief\brief Aaa 242 test_attach10, 243 244 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 245 test_attach11 ///< \brief\brief Aaa 246}; 247 248// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 249/// \brief\brief Aaa 250struct test_noattach12 *test_attach13; 251 252// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 253/// \brief\brief Aaa 254typedef struct test_noattach14 *test_attach15; 255 256// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 257/// \brief\brief Aaa 258typedef struct test_attach16 { int a; } test_attach17; 259 260struct S { int a; }; 261 262// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 263/// \brief\brief Aaa 264struct S *test_attach18; 265 266// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 267/// \brief\brief Aaa 268typedef struct S *test_attach19; 269 270// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 271/// \brief\brief Aaa 272struct test_attach20; 273 274// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 275/// \brief\brief Aaa 276typedef struct test_attach21 { 277 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 278 /// \brief\brief Aaa 279 int test_attach22; 280} test_attach23; 281 282// expected-warning@+1 {{empty paragraph passed to '\brief' command}} 283/// \brief\brief Aaa 284namespace test_attach24 { 285 // expected-warning@+1 {{empty paragraph passed to '\brief' command}} 286 /// \brief\brief Aaa 287 namespace test_attach25 { 288 } 289} 290 291// PR13411, reduced. We used to crash on this. 292/** 293 * @code Aaa. 294 */ 295void test_nocrash1(int); 296 297