warn-documentation.cpp revision 858e69fe1305bdffb76a200c0f498685f11e65ae
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
170// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
171int test1; ///< \brief\brief Aaa
172
173// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
174// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
175int test2, ///< \brief\brief Aaa
176    test3; ///< \brief\brief Aaa
177
178// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
179int test4; ///< \brief
180           ///< \brief Aaa
181
182
183// Check that we attach the comment to the declaration during parsing in the
184// following cases.  The test is based on the fact that we don't parse
185// documentation comments that are not attached to anything.
186
187// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
188/// \brief\brief Aaa
189int test_attach1;
190
191// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
192/// \brief\brief Aaa
193int test_attach2(int);
194
195// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
196/// \brief\brief Aaa
197struct test_attach3 {
198  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
199  /// \brief\brief Aaa
200  int test_attach4;
201
202  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
203  int test_attach5; ///< \brief\brief Aaa
204
205  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
206  /// \brief\brief Aaa
207  int test_attach6(int);
208};
209
210// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
211/// \brief\brief Aaa
212class test_attach7 {
213  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
214  /// \brief\brief Aaa
215  int test_attach8;
216
217  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
218  int test_attach9; ///< \brief\brief Aaa
219
220  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
221  /// \brief\brief Aaa
222  int test_attach10(int);
223};
224
225// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
226/// \brief\brief Aaa
227enum test_attach9 {
228  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
229  /// \brief\brief Aaa
230  test_attach10,
231
232  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
233  test_attach11 ///< \brief\brief Aaa
234};
235
236// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
237/// \brief\brief Aaa
238struct test_noattach12 *test_attach13;
239
240// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
241/// \brief\brief Aaa
242typedef struct test_noattach14 *test_attach15;
243
244// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
245/// \brief\brief Aaa
246typedef struct test_attach16 { int a; } test_attach17;
247
248struct S { int a; };
249
250// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
251/// \brief\brief Aaa
252struct S *test_attach18;
253
254// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
255/// \brief\brief Aaa
256typedef struct S *test_attach19;
257
258// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
259/// \brief\brief Aaa
260struct test_attach20;
261
262// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
263/// \brief\brief Aaa
264typedef struct test_attach21 {
265  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
266  /// \brief\brief Aaa
267  int test_attach22;
268} test_attach23;
269
270// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
271/// \brief\brief Aaa
272namespace test_attach24 {
273  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
274  /// \brief\brief Aaa
275  namespace test_attach25 {
276  }
277}
278
279