blob: 61c535eb576ef45b554019a341df994c2b9e7c99 [file] [log] [blame]
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +00001// 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}}
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000012// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000013/// <a href= blah
14int test_html3(int);
15
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000016// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000017/// <a =>
18int test_html4(int);
19
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000020// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000021/// <a "aaa">
22int test_html5(int);
23
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000024// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000025/// <a a="b" =>
26int test_html6(int);
27
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000028// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000029/// <a a="b" "aaa">
30int test_html7(int);
31
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000032// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000033/// <a a="b" =
34int test_html8(int);
35
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000036// expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000037/** Aaa bbb<ccc ddd eee
38 * fff ggg.
39 */
40int test_html9(int);
41
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000042// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000043/** Aaa bbb<ccc ddd eee 42%
44 * fff ggg.
45 */
46int test_html10(int);
47
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000048// expected-warning@+1 {{HTML end tag 'br' is forbidden}}
Dmitri Gribenko3d986982012-07-12 23:37:09 +000049/// <br></br>
50int test_html11(int);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000051
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
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000066// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000067/// <b><i>Meow</a>
68int test_html_nesting5(int);
69
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000070// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
71// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000072/// <b><i>Meow</b></b>
73int test_html_nesting6(int);
74
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000075// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
76// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000077/// <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
Dmitri Gribenko858e69f2012-07-19 00:01:56 +0000107/// \brief \c Aaa
108int test_block_command6(int);
109
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000110// 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
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000147// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
148/// \param a Blah blah.
149int test_param11();
150
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000151// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
152/// \param A Blah blah.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000153int test_param12(int a);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000154
155// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
156/// \param aab Blah blah.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000157int test_param13(int aaa, int bbb);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000158
159// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
160/// \param aab Blah blah.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000161int test_param14(int bbb, int ccc);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000162
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.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000170 int test_param15(int bbb, int ccc);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000171};
172
Dmitri Gribenko65822772012-07-24 21:44:16 +0000173// expected-warning@+3 {{parameter 'a' is already documented}}
174// expected-note@+1 {{previous documentation}}
175/// \param a Aaa.
176/// \param a Aaa.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000177int test_param16(int a);
Dmitri Gribenko65822772012-07-24 21:44:16 +0000178
179// expected-warning@+4 {{parameter 'x2' is already documented}}
180// expected-note@+2 {{previous documentation}}
181/// \param x1 Aaa.
182/// \param x2 Bbb.
183/// \param x2 Ccc.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000184int test_param17(int x1, int x2, int x3);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000185
186// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
187int test1; ///< \brief\brief Aaa
188
189// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
190// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
191int test2, ///< \brief\brief Aaa
192 test3; ///< \brief\brief Aaa
193
194// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
195int test4; ///< \brief
196 ///< \brief Aaa
197
198
199// Check that we attach the comment to the declaration during parsing in the
200// following cases. The test is based on the fact that we don't parse
201// documentation comments that are not attached to anything.
202
203// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
204/// \brief\brief Aaa
205int test_attach1;
206
207// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
208/// \brief\brief Aaa
209int test_attach2(int);
210
211// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
212/// \brief\brief Aaa
213struct test_attach3 {
214 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
215 /// \brief\brief Aaa
216 int test_attach4;
217
218 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
219 int test_attach5; ///< \brief\brief Aaa
220
221 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
222 /// \brief\brief Aaa
223 int test_attach6(int);
224};
225
226// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
227/// \brief\brief Aaa
228class test_attach7 {
229 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
230 /// \brief\brief Aaa
231 int test_attach8;
232
233 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
234 int test_attach9; ///< \brief\brief Aaa
235
236 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
237 /// \brief\brief Aaa
238 int test_attach10(int);
239};
240
241// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
242/// \brief\brief Aaa
243enum test_attach9 {
244 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
245 /// \brief\brief Aaa
246 test_attach10,
247
248 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
249 test_attach11 ///< \brief\brief Aaa
250};
251
252// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
253/// \brief\brief Aaa
254struct test_noattach12 *test_attach13;
255
256// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
257/// \brief\brief Aaa
258typedef struct test_noattach14 *test_attach15;
259
260// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
261/// \brief\brief Aaa
262typedef struct test_attach16 { int a; } test_attach17;
263
264struct S { int a; };
265
266// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
267/// \brief\brief Aaa
268struct S *test_attach18;
269
270// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
271/// \brief\brief Aaa
272typedef struct S *test_attach19;
273
274// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
275/// \brief\brief Aaa
276struct test_attach20;
277
278// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
279/// \brief\brief Aaa
280typedef struct test_attach21 {
281 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
282 /// \brief\brief Aaa
283 int test_attach22;
284} test_attach23;
285
286// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
287/// \brief\brief Aaa
288namespace test_attach24 {
289 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
290 /// \brief\brief Aaa
291 namespace test_attach25 {
292 }
293}
294
Dmitri Gribenko9f08f492012-07-20 20:18:53 +0000295// PR13411, reduced. We used to crash on this.
296/**
297 * @code Aaa.
298 */
299void test_nocrash1(int);
300