warn-documentation.cpp revision 3f38bf2d441fac379c427f86153fbb0cb41256c6
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// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
108/// \param a Blah blah.
109int test_param1;
110
111// expected-warning@+1 {{empty paragraph passed to '\param' command}}
112/// \param
113/// \param a Blah blah.
114int test_param2(int a);
115
116// expected-warning@+1 {{empty paragraph passed to '\param' command}}
117/// \param a
118int test_param3(int a);
119
120/// \param a Blah blah.
121int test_param4(int a);
122
123/// \param [in] a Blah blah.
124int test_param5(int a);
125
126/// \param [out] a Blah blah.
127int test_param6(int a);
128
129/// \param [in,out] a Blah blah.
130int test_param7(int a);
131
132// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
133/// \param [ in ] a Blah blah.
134int test_param8(int a);
135
136// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
137/// \param [in, out] a Blah blah.
138int test_param9(int a);
139
140// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
141/// \param [ junk] a Blah blah.
142int test_param10(int a);
143
144// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
145/// \param A Blah blah.
146int test_param11(int a);
147
148// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
149/// \param aab Blah blah.
150int test_param12(int aaa, int bbb);
151
152// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
153/// \param aab Blah blah.
154int test_param13(int bbb, int ccc);
155
156class C {
157  // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
158  /// \param aaa Blah blah.
159  C(int bbb, int ccc);
160
161  // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
162  /// \param aaa Blah blah.
163 int test_param14(int bbb, int ccc);
164};
165
166
167// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
168int test1; ///< \brief\brief Aaa
169
170// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
171// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
172int test2, ///< \brief\brief Aaa
173    test3; ///< \brief\brief Aaa
174
175// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
176int test4; ///< \brief
177           ///< \brief Aaa
178
179
180// Check that we attach the comment to the declaration during parsing in the
181// following cases.  The test is based on the fact that we don't parse
182// documentation comments that are not attached to anything.
183
184// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
185/// \brief\brief Aaa
186int test_attach1;
187
188// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
189/// \brief\brief Aaa
190int test_attach2(int);
191
192// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
193/// \brief\brief Aaa
194struct test_attach3 {
195  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
196  /// \brief\brief Aaa
197  int test_attach4;
198
199  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
200  int test_attach5; ///< \brief\brief Aaa
201
202  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
203  /// \brief\brief Aaa
204  int test_attach6(int);
205};
206
207// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
208/// \brief\brief Aaa
209class test_attach7 {
210  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
211  /// \brief\brief Aaa
212  int test_attach8;
213
214  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
215  int test_attach9; ///< \brief\brief Aaa
216
217  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
218  /// \brief\brief Aaa
219  int test_attach10(int);
220};
221
222// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
223/// \brief\brief Aaa
224enum test_attach9 {
225  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
226  /// \brief\brief Aaa
227  test_attach10,
228
229  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
230  test_attach11 ///< \brief\brief Aaa
231};
232
233// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
234/// \brief\brief Aaa
235struct test_noattach12 *test_attach13;
236
237// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
238/// \brief\brief Aaa
239typedef struct test_noattach14 *test_attach15;
240
241// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
242/// \brief\brief Aaa
243typedef struct test_attach16 { int a; } test_attach17;
244
245struct S { int a; };
246
247// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
248/// \brief\brief Aaa
249struct S *test_attach18;
250
251// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
252/// \brief\brief Aaa
253typedef struct S *test_attach19;
254
255// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
256/// \brief\brief Aaa
257struct test_attach20;
258
259// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
260/// \brief\brief Aaa
261typedef struct test_attach21 {
262  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
263  /// \brief\brief Aaa
264  int test_attach22;
265} test_attach23;
266
267// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
268/// \brief\brief Aaa
269namespace test_attach24 {
270  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
271  /// \brief\brief Aaa
272  namespace test_attach25 {
273  }
274}
275
276