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=>
5 int test_html1(int);
6 
7 // expected-warning@+1 {{expected quoted string after equals sign}}
8 /// <a href==>
9 int 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
14 int test_html3(int);
15 
16 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
17 /// <a =>
18 int test_html4(int);
19 
20 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
21 /// <a "aaa">
22 int test_html5(int);
23 
24 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
25 /// <a a="b" =>
26 int test_html6(int);
27 
28 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
29 /// <a a="b" "aaa">
30 int test_html7(int);
31 
32 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
33 /// <a a="b" =
34 int 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  */
40 int 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  */
46 int test_html10(int);
47 
48 // expected-warning@+1 {{HTML end tag 'br' is forbidden}}
49 /// <br></br>
50 int test_html11(int);
51 
52 /// <blockquote>Meow</blockquote>
53 int test_html_nesting1(int);
54 
55 /// <b><i>Meow</i></b>
56 int test_html_nesting2(int);
57 
58 /// <p>Aaa<br>
59 /// Bbb</p>
60 int test_html_nesting3(int);
61 
62 /// <p>Aaa<br />
63 /// Bbb</p>
64 int test_html_nesting4(int);
65 
66 // expected-warning@+1 {{HTML end tag does not match any start tag}}
67 /// <b><i>Meow</a>
68 int 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>
73 int 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>
78 int test_html_nesting7(int);
79 
80 
81 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
82 /// \brief\brief Aaa
83 int test_block_command1(int);
84 
85 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
86 /// \brief \brief Aaa
87 int test_block_command2(int);
88 
89 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
90 /// \brief
91 /// \brief Aaa
92 int test_block_command3(int);
93 
94 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
95 /// \brief
96 ///
97 /// \brief Aaa
98 int 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
105 int test_block_command5(int);
106 
107 /// \brief \c Aaa
108 int 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.
112 int test_param1;
113 
114 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
115 /// \param
116 /// \param a Blah blah.
117 int test_param2(int a);
118 
119 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
120 /// \param a
121 int test_param3(int a);
122 
123 /// \param a Blah blah.
124 int test_param4(int a);
125 
126 /// \param [in] a Blah blah.
127 int test_param5(int a);
128 
129 /// \param [out] a Blah blah.
130 int test_param6(int a);
131 
132 /// \param [in,out] a Blah blah.
133 int test_param7(int a);
134 
135 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
136 /// \param [ in ] a Blah blah.
137 int test_param8(int a);
138 
139 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
140 /// \param [in, out] a Blah blah.
141 int 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.
145 int test_param10(int a);
146 
147 // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
148 /// \param a Blah blah.
149 int 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.
153 int 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.
157 int test_param13(int aaa, int bbb);
158 
159 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
160 /// \param aab Blah blah.
161 int test_param14(int bbb, int ccc);
162 
163 class 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@+3 {{parameter 'a' is already documented}}
174 // expected-note@+1 {{previous documentation}}
175 /// \param a Aaa.
176 /// \param a Aaa.
177 int test_param16(int a);
178 
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.
184 int test_param17(int x1, int x2, int x3);
185 
186 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
187 int 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}}
191 int test2, ///< \brief\brief Aaa
192     test3; ///< \brief\brief Aaa
193 
194 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
195 int 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
205 int test_attach1;
206 
207 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
208 /// \brief\brief Aaa
209 int test_attach2(int);
210 
211 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
212 /// \brief\brief Aaa
213 struct 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
228 class 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
243 enum 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
254 struct test_noattach12 *test_attach13;
255 
256 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
257 /// \brief\brief Aaa
258 typedef struct test_noattach14 *test_attach15;
259 
260 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
261 /// \brief\brief Aaa
262 typedef struct test_attach16 { int a; } test_attach17;
263 
264 struct S { int a; };
265 
266 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
267 /// \brief\brief Aaa
268 struct S *test_attach18;
269 
270 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
271 /// \brief\brief Aaa
272 typedef struct S *test_attach19;
273 
274 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
275 /// \brief\brief Aaa
276 struct test_attach20;
277 
278 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
279 /// \brief\brief Aaa
280 typedef 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
288 namespace test_attach24 {
289   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
290   /// \brief\brief Aaa
291   namespace test_attach25 {
292   }
293 }
294 
295 // PR13411, reduced.  We used to crash on this.
296 /**
297  * @code Aaa.
298  */
299 void test_nocrash1(int);
300 
301 // We used to crash on this.
302 // expected-warning@+2 {{empty paragraph passed to '\param' command}}
303 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
304 /// \param\brief
305 void test_nocrash2(int);
306 
307