xref: /llvm-project/clang/test/Sema/warn-documentation.cpp (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
2 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
3 
4 // This file contains lots of corner cases, so ensure that XML we generate is not invalid.
5 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
6 // WRONG-NOT: CommentXMLInvalid
7 
8 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
9 // expected-warning@+1 {{expected quoted string after equals sign}}
10 /// <a href=>
11 int test_html1(int);
12 
13 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
14 // expected-warning@+1 {{expected quoted string after equals sign}}
15 /// <a href==>
16 int test_html2(int);
17 
18 // expected-warning@+3 {{HTML tag 'a' requires an end tag}}
19 // expected-warning@+2 {{expected quoted string after equals sign}}
20 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
21 /// <a href= blah
22 int test_html3(int);
23 
24 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
25 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
26 /// <a =>
27 int test_html4(int);
28 
29 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
30 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
31 /// <a "aaa">
32 int test_html5(int);
33 
34 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
35 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
36 /// <a a="b" =>
37 int test_html6(int);
38 
39 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
40 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
41 /// <a a="b" "aaa">
42 int test_html7(int);
43 
44 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
45 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
46 /// <a a="b" =
47 int test_html8(int);
48 
49 // expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
50 /** Aaa bbb<img ddd eee
51  * fff ggg.
52  */
53 int test_html9(int);
54 
55 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
56 /** Aaa bbb<img ddd eee 42%
57  * fff ggg.
58  */
59 int test_html10(int);
60 
61 // expected-warning@+1 {{HTML end tag 'br' is forbidden}}
62 /// <br></br>
63 int test_html11(int);
64 
65 /// Aaa bbb<img/>
66 int test_html12(int);
67 
68 /// Aaa bbb<img />
69 int test_html13(int);
70 
71 /// Aaa bbb<img src="">
72 int test_html14(int);
73 
74 /// Aaa bbb<img src=""/>
75 int test_html15(int);
76 
77 /// Aaa bbb<img src="" />
78 int test_html16(int);
79 
80 /// <blockquote>Meow</blockquote>
81 int test_html_nesting1(int);
82 
83 /// <b><i>Meow</i></b>
84 int test_html_nesting2(int);
85 
86 /// <p>Aaa<br>
87 /// Bbb</p>
88 int test_html_nesting3(int);
89 
90 /// <p>Aaa<br />
91 /// Bbb</p>
92 int test_html_nesting4(int);
93 
94 // expected-warning@+3 {{HTML tag 'b' requires an end tag}}
95 // expected-warning@+2 {{HTML tag 'i' requires an end tag}}
96 // expected-warning@+1 {{HTML end tag does not match any start tag}}
97 /// <b><i>Meow</a>
98 int test_html_nesting5(int);
99 
100 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
101 // expected-warning@+1 {{HTML end tag does not match any start tag}}
102 /// <b><i>Meow</b></b>
103 int test_html_nesting6(int);
104 
105 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
106 // expected-warning@+1 {{HTML end tag does not match any start tag}}
107 /// <b><i>Meow</b></i>
108 int test_html_nesting7(int);
109 
110 // expected-warning@+1 {{HTML tag 'b' requires an end tag}}
111 /// <b>Meow
112 int test_html_nesting8(int);
113 
114 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
115 /// \brief\returns Aaa
116 int test_block_command1(int);
117 
118 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
119 /// \brief \returns Aaa
120 int test_block_command2(int);
121 
122 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
123 /// \brief
124 /// \returns Aaa
125 int test_block_command3(int);
126 
127 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
128 /// \brief
129 ///
130 /// \returns Aaa
131 int test_block_command4(int);
132 
133 // There is trailing whitespace on one of the following lines, don't remove it!
134 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
135 /// \brief
136 ///
137 /// \returns Aaa
138 int test_block_command5(int);
139 
140 /// \brief \c Aaa
141 int test_block_command6(int);
142 
143 // We don't recognize comments in double quotes.
144 /// "\brief \returns Aaa"
145 int test_block_command7(int);
146 
147 // But only if they're single-line. (Doxygen treats multi-line quotes inconsistently.)
148 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
149 /// "\brief
150 /// \returns Aaa"
151 int test_block_command8(int);
152 
153 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
154 /// \brief Aaa
155 ///
156 /// Bbb
157 ///
158 /// \brief Ccc
159 int test_duplicate_brief1(int);
160 
161 // expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
162 /// \short Aaa
163 ///
164 /// Bbb
165 ///
166 /// \short Ccc
167 int test_duplicate_brief2(int);
168 
169 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
170 /// \short Aaa
171 ///
172 /// Bbb
173 ///
174 /// \brief Ccc
175 int test_duplicate_brief3(int);
176 
177 
178 /// \return Aaa
179 ///
180 /// Bbb
181 ///
182 /// \return Ccc
183 int test_multiple_returns1(int);
184 
185 /// \returns Aaa
186 ///
187 /// Bbb
188 ///
189 /// \returns Ccc
190 int test_multiple_returns2(int);
191 
192 /// \result Aaa
193 ///
194 /// Bbb
195 ///
196 /// \result Ccc
197 int test_multiple_returns3(int);
198 
199 /// \returns Aaa
200 ///
201 /// Bbb
202 ///
203 /// \return Ccc
204 int test_multiple_returns4(int);
205 
206 
207 /// expected-warning@+1 {{empty paragraph passed to '\retval' command}}
208 /// \retval 0
209 int test_retval_no_paragraph();
210 
211 /// \retval 0 Everything is fine.
212 int test_retval_fine();
213 
214 
215 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
216 /// \param a Blah blah.
217 int test_param1_backslash;
218 
219 // Check that the diagnostic uses the same command marker as the comment.
220 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
221 /// @param a Blah blah.
222 int test_param1_at;
223 
224 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
225 /// \param
226 /// \param a Blah blah.
227 int test_param2(int a);
228 
229 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
230 /// \param a
231 int test_param3(int a);
232 
233 /// \param a Blah blah.
234 int test_param4(int a);
235 
236 /// \param [in] a Blah blah.
237 int test_param5(int a);
238 
239 /// \param [out] a Blah blah.
240 int test_param6(int a);
241 
242 /// \param [in,out] a Blah blah.
243 int test_param7(int a);
244 
245 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
246 /// \param [ in ] a Blah blah.
247 int test_param8(int a);
248 
249 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
250 /// \param [in, out] a Blah blah.
251 int test_param9(int a);
252 
253 // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
254 /// \param [ junk] a Blah blah.
255 int test_param10(int a);
256 
257 // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
258 /// \param a Blah blah.
259 int test_param11();
260 
261 // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
262 /// \param A Blah blah.
263 int test_param12(int a);
264 
265 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
266 /// \param aab Blah blah.
267 int test_param13(int aaa, int bbb);
268 
269 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
270 /// \param aaa Blah blah.
271 /// \param aab Blah blah.
272 int test_param14(int aaa, int bbb);
273 
274 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
275 /// \param aab Blah blah.
276 int test_param15(int bbb, int ccc);
277 
278 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
279 /// \param aab Ccc.
280 /// \param aaa Aaa.
281 /// \param bbb Bbb.
282 int test_param16(int aaa, int bbb);
283 
284 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
285 /// \param aaa Aaa.
286 /// \param aab Ccc.
287 /// \param bbb Bbb.
288 int test_param17(int aaa, int bbb);
289 
290 // expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
291 /// \param aaa Aaa.
292 /// \param bbb Bbb.
293 /// \param aab Ccc.
294 int test_param18(int aaa, int bbb);
295 
296 class C {
297   // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
298   /// \param aaa Blah blah.
299   C(int bbb, int ccc);
300 
301   // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
302   /// \param aaa Blah blah.
303  int test_param19(int bbb, int ccc);
304 };
305 
306 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
307 /// \param aab Blah blah.
308 template<typename T>
309 void test_param20(int bbb, int ccc);
310 
311 // expected-warning@+3 {{parameter 'a' is already documented}}
312 // expected-note@+1 {{previous documentation}}
313 /// \param a Aaa.
314 /// \param a Aaa.
315 int test_param21(int a);
316 
317 // expected-warning@+4 {{parameter 'x2' is already documented}}
318 // expected-note@+2 {{previous documentation}}
319 /// \param x1 Aaa.
320 /// \param x2 Bbb.
321 /// \param x2 Ccc.
322 int test_param22(int x1, int x2, int x3);
323 
324 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
325 /// \param a
326 /// \retval 0 Blah blah.
327 int test_param23(int a);
328 
329 /// \param a \ref test_param23 has an empty paragraph, this doesn't.
330 int test_param24(int a);
331 
332 //===---
333 // Test that we treat typedefs to some non-function types as functions for the
334 // purposes of documentation comment parsing.
335 //===---
336 
337 namespace foo {
338   inline namespace bar {
339     template<typename>
340     struct function_wrapper {};
341 
342     template<unsigned>
343     struct not_a_function_wrapper {};
344   }
345 };
346 
347 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
348 /// \param aaa Meow.
349 /// \param bbb Bbb.
350 /// \returns aaa.
351 typedef int test_function_like_typedef1(int aaa, int ccc);
352 
353 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
354 /// \param aaa Meow.
355 /// \param bbb Bbb.
356 /// \returns aaa.
357 typedef int (*test_function_like_typedef2)(int aaa, int ccc);
358 
359 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
360 /// \param aaa Meow.
361 /// \param bbb Bbb.
362 /// \returns aaa.
363 typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
364 
365 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
366 /// \param aaa Meow.
367 /// \param bbb Bbb.
368 /// \returns aaa.
369 typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
370 
371 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
372 /// \param aaa Meow.
373 /// \param bbb Bbb.
374 /// \returns aaa.
375 typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
376 
377 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
378 /// \param aaa Meow.
379 /// \param bbb Bbb.
380 /// \returns aaa.
381 typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
382 
383 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
384 /// \param aaa Meow.
385 /// \param bbb Bbb.
386 /// \returns aaa.
387 typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
388 
389 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
390 /// \param aaa Meow.
391 /// \param bbb Bbb.
392 /// \returns aaa.
393 typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
394 
395 
396 typedef int (*test_not_function_like_typedef1)(int aaa);
397 
398 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
399 /// \param aaa Meow.
400 typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
401 
402 // Check that the diagnostic uses the same command marker as the comment.
403 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
404 /// @param aaa Meow.
405 typedef unsigned int test_not_function_like_typedef3;
406 
407 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
408 /// \param aaa Meow.
409 typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
410 
411 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
412 /// \param aaa Meow.
413 /// \param bbb Bbb.
414 /// \returns aaa.
415 using test_function_like_using1 = int (int aaa, int ccc);
416 
417 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
418 /// \param aaa Meow.
419 /// \param bbb Bbb.
420 /// \returns aaa.
421 using test_function_like_using2 = int (*)(int aaa, int ccc);
422 
423 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
424 /// \param aaa Meow.
425 /// \param bbb Bbb.
426 /// \returns aaa.
427 using test_function_like_using3 = int (* const)(int aaa, int ccc);
428 
429 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
430 /// \param aaa Meow.
431 /// \param bbb Bbb.
432 /// \returns aaa.
433 using test_function_like_using4 = int (C::*)(int aaa, int ccc);
434 
435 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
436 /// \param aaa Meow.
437 /// \param bbb Bbb.
438 /// \returns aaa.
439 using test_function_like_using5 = foo::function_wrapper<int (int aaa, int ccc)>;
440 
441 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
442 /// \param aaa Meow.
443 /// \param bbb Bbb.
444 /// \returns aaa.
445 using test_function_like_using6 = foo::function_wrapper<int (int aaa, int ccc)> *;
446 
447 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
448 /// \param aaa Meow.
449 /// \param bbb Bbb.
450 /// \returns aaa.
451 using test_function_like_using7 = foo::function_wrapper<int (int aaa, int ccc)> &;
452 
453 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
454 /// \param aaa Meow.
455 /// \param bbb Bbb.
456 /// \returns aaa.
457 using test_function_like_using8 = foo::function_wrapper<int (int aaa, int ccc)> &&;
458 
459 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
460 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
461 /// \param aaa Meow.
462 /// \param bbb Bbb.
463 /// \tparam U Uuu.
464 template<typename T>
465 using test_function_like_using9 = int(T aaa, int ccc);
466 
467 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
468 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
469 /// \param aaa Meow.
470 /// \param bbb Bbb.
471 /// \tparam U Uuu.
472 template<typename T>
473 using test_function_like_using10 = int (*)(T aaa, int ccc);
474 
475 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
476 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
477 /// \param aaa Meow.
478 /// \param bbb Bbb.
479 /// \tparam U Uuu.
480 template<typename T>
481 using test_function_like_using11 = foo::function_wrapper<int (T aaa, int ccc)>;
482 
483 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
484 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
485 /// \param aaa Meow.
486 /// \param bbb Bbb.
487 /// \tparam U Uuu.
488 template<typename T>
489 using test_function_like_using12 = foo::function_wrapper<int (T aaa, int ccc)> *;
490 
491 using test_not_function_like_using1 = int (*)(int aaa);
492 
493 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
494 /// \param aaa Meow.
495 using test_not_function_like_using2 = test_not_function_like_using1;
496 
497 // Check that the diagnostic uses the same command marker as the comment.
498 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
499 /// @param aaa Meow.
500 using test_not_function_like_using3 = unsigned int;
501 
502 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
503 /// \param aaa Meow.
504 using test_not_function_like_using4 = foo::not_a_function_wrapper<1>;
505 
506 /// \param aaa Aaa
507 /// \param ... Vararg
508 int test_vararg_param1(int aaa, ...);
509 
510 /// \param ... Vararg
511 int test_vararg_param2(...);
512 
513 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
514 /// \param ... Vararg
515 int test_vararg_param3(int aaa);
516 
517 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
518 /// \param ... Vararg
519 int test_vararg_param4();
520 
521 
522 /// \param aaa Aaa
523 /// \param ... Vararg
524 template<typename T>
525 int test_template_vararg_param1(int aaa, ...);
526 
527 /// \param ... Vararg
528 template<typename T>
529 int test_template_vararg_param2(...);
530 
531 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
532 /// \param ... Vararg
533 template<typename T>
534 int test_template_vararg_param3(int aaa);
535 
536 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
537 /// \param ... Vararg
538 template<typename T>
539 int test_template_vararg_param4();
540 
541 
542 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
543 /// \tparam T Aaa
544 int test_tparam1;
545 
546 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
547 /// \tparam T Aaa
548 void test_tparam2(int aaa);
549 
550 // expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
551 /// \tparam
552 /// \param aaa Blah blah
553 template<typename T>
554 void test_tparam3(T aaa);
555 
556 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
557 /// \tparam T Aaa
558 template<typename TT>
559 void test_tparam4(TT aaa);
560 
561 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
562 /// \tparam T Aaa
563 template<typename TT>
564 class test_tparam5 {
565   // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
566   /// \tparam T Aaa
567   template<typename TTT>
568   void test_tparam6(TTT aaa);
569 };
570 
571 /// \tparam T1 Aaa
572 /// \tparam T2 Bbb
573 template<typename T1, typename T2>
574 void test_tparam7(T1 aaa, T2 bbb);
575 
576 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
577 /// \tparam SomTy Aaa
578 /// \tparam OtherTy Bbb
579 template<typename SomeTy, typename OtherTy>
580 void test_tparam8(SomeTy aaa, OtherTy bbb);
581 
582 // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
583 /// \tparam T1 Aaa
584 /// \tparam T1 Bbb
585 template<typename T1, typename T2>
586 void test_tparam9(T1 aaa, T2 bbb);
587 
588 /// \tparam T Aaa
589 /// \tparam TT Bbb
590 template<template<typename T> class TT>
591 void test_tparam10(TT<int> aaa);
592 
593 /// \tparam T Aaa
594 /// \tparam TT Bbb
595 /// \tparam TTT Ccc
596 template<template<template<typename T> class TT, class C> class TTT>
597 void test_tparam11();
598 
599 /// \tparam I Aaa
600 template<int I>
601 void test_tparam12();
602 
603 template<typename T, typename U>
604 class test_tparam13 { };
605 
606 /// \tparam T Aaa
607 template<typename T>
608 using test_tparam14 = test_tparam13<T, int>;
609 
610 // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
611 /// \tparam U Aaa
612 template<typename T>
613 using test_tparam15 = test_tparam13<T, int>;
614 
615 // ----
616 
617 /// \tparam T Aaa
618 template<typename T>
619 class test_tparam16 { };
620 
621 typedef test_tparam16<int> test_tparam17;
622 typedef test_tparam16<double> test_tparam18;
623 
624 // ----
625 
626 template<typename T>
627 class test_tparam19;
628 
629 typedef test_tparam19<int> test_tparam20;
630 typedef test_tparam19<double> test_tparam21;
631 
632 /// \tparam T Aaa
633 template<typename T>
634 class test_tparam19 { };
635 
636 // ----
637 
638 // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
639 /// @tparam T Aaa
640 int test_tparam22;
641 
642 // ----
643 
644 
645 /// Aaa
646 /// \deprecated Bbb
647 void test_deprecated_1(int a) __attribute__((deprecated));
648 
649 #if __cplusplus >= 201402L
650 /// Aaa
651 /// \deprecated Bbb
652 [[deprecated]] void test_deprecated_no_warning_std14(int a);
653 #endif
654 
655 // We don't want \deprecated to warn about empty paragraph.  It is fine to use
656 // \deprecated by itself without explanations.
657 
658 /// Aaa
659 /// \deprecated
660 void test_deprecated_2(int a) __attribute__((deprecated));
661 
662 /// Aaa
663 /// \deprecated
664 void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
665 
666 /// Aaa
667 /// \deprecated
668 void test_deprecated_4(int a) __attribute__((unavailable));
669 
670 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
671 /// Aaa
672 /// \deprecated
673 void test_deprecated_5(int a);
674 
675 // expected-warning@+2 {{declaration is marked with '@deprecated' command but does not have a deprecation attribute}} expected-note@+3 {{add a deprecation attribute to the declaration to silence this warning}}
676 /// Aaa
677 /// @deprecated
test_deprecated_6(int a)678 void test_deprecated_6(int a) {
679 }
680 
681 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
682 /// Aaa
683 /// \deprecated
684 template<typename T>
685 void test_deprecated_7(T aaa);
686 
687 class PR43753 {
688   // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
689   // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
690   /// \deprecated
691   static void test_deprecated_static();
692 
693   // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
694   // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
695   /// \deprecated
696   static auto test_deprecated_static_trailing_return() -> int;
697 
698 #if __cplusplus >= 201402L
699   // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
700   // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
701   /// \deprecated
test_deprecated_static_decltype_auto()702   static decltype(auto) test_deprecated_static_decltype_auto() { return 1; }
703 #endif
704 
705   // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
706   // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
707   /// \deprecated
708   void test_deprecated_const() const;
709 
710   // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
711   // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
712   /// \deprecated
713   auto test_deprecated_trailing_return() -> int;
714 
715 #if __cplusplus >= 201402L
716   // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
717   // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
718   /// \deprecated
test_deprecated_decltype_auto() const719   decltype(auto) test_deprecated_decltype_auto() const { return a; }
720 
721 private:
722   int a{0};
723 #endif
724 };
725 
726 // expected-note@+2 {{previous command '\headerfile' here}}
727 // expected-warning@+2 {{duplicated command '\headerfile'}}
728 /// \headerfile ""
729 /// \headerfile foo.h
730 int test__headerfile_1(int a);
731 
732 
733 /// \invariant aaa
734 void test_invariant_1(int a);
735 
736 // expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
737 /// \invariant
738 void test_invariant_2(int a);
739 
740 
741 // no-warning
742 /// \returns Aaa
743 int test_returns_right_decl_1(int);
744 
745 class test_returns_right_decl_2 {
746   // no-warning
747   /// \returns Aaa
748   int test_returns_right_decl_3(int);
749 };
750 
751 // no-warning
752 /// \returns Aaa
753 template<typename T>
754 int test_returns_right_decl_4(T aaa);
755 
756 // no-warning
757 /// \returns Aaa
758 template<>
759 int test_returns_right_decl_4(int aaa);
760 
761 /// \returns Aaa
762 template<typename T>
763 T test_returns_right_decl_5(T aaa);
764 
765 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
766 /// \returns Aaa
767 int test_returns_wrong_decl_1_backslash;
768 
769 // Check that the diagnostic uses the same command marker as the comment.
770 // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
771 /// @returns Aaa
772 int test_returns_wrong_decl_1_at;
773 
774 // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
775 /// \return Aaa
776 int test_returns_wrong_decl_2;
777 
778 // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
779 /// \result Aaa
780 int test_returns_wrong_decl_3;
781 
782 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
783 /// \returns Aaa
784 void test_returns_wrong_decl_4(int);
785 
786 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
787 /// \returns Aaa
788 template<typename T>
789 void test_returns_wrong_decl_5(T aaa);
790 
791 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
792 /// \returns Aaa
793 template<>
794 void test_returns_wrong_decl_5(int aaa);
795 
796 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
797 /// \returns Aaa
798 struct test_returns_wrong_decl_6 { };
799 
800 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
801 /// \returns Aaa
802 class test_returns_wrong_decl_7 {
803   // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
804   /// \returns Aaa
805   test_returns_wrong_decl_7();
806 
807   // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
808   /// \returns Aaa
809   ~test_returns_wrong_decl_7();
810 };
811 
812 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
813 /// \returns Aaa
814 enum test_returns_wrong_decl_8 {
815   // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
816   /// \returns Aaa
817   test_returns_wrong_decl_9
818 };
819 
820 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
821 /// \returns Aaa
822 namespace test_returns_wrong_decl_10 { };
823 
824 // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
825 /*!	@function test_function
826 */
827 typedef unsigned int Base64Flags;
828 unsigned test_function(Base64Flags inFlags);
829 
830 // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
831 /*! @callback test_callback
832 */
833 typedef unsigned int BaseFlags;
834 unsigned (*test_callback)(BaseFlags inFlags);
835 
836 // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
837 /// \endverbatim
838 int test_verbatim_1();
839 
840 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
841 /// \endcode
842 int test_verbatim_2();
843 
844 // FIXME: we give a bad diagnostic here because we throw away non-documentation
845 // comments early.
846 //
847 // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
848 /// \code
849 //  foo
850 /// \endcode
851 int test_verbatim_3();
852 
853 
854 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
855 int test1; ///< \brief\author Aaa
856 
857 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
858 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
859 int test2, ///< \brief\author Aaa
860     test3; ///< \brief\author Aaa
861 
862 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
863 int test4; ///< \brief
864            ///< \author Aaa
865 
866 
867 class TestRelates {};
868 
869 /// \relates TestRelates
870 /// \brief Aaa
871 void test_relates_1();
872 
873 /// \related TestRelates
874 /// \brief Aaa
875 void test_relates_2();
876 
877 /// \relatesalso TestRelates
878 /// \brief Aaa
879 void test_relates_3();
880 
881 /// \relatedalso TestRelates
882 /// \brief Aaa
883 void test_relates_4();
884 
885 
886 // Check that we attach the comment to the declaration during parsing in the
887 // following cases.  The test is based on the fact that we don't parse
888 // documentation comments that are not attached to anything.
889 
890 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
891 /// \brief\author Aaa
892 int test_attach1;
893 
894 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
895 /// \brief\author Aaa
896 int test_attach2(int);
897 
898 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
899 /// \brief\author Aaa
900 struct test_attach3 {
901   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
902   /// \brief\author Aaa
903   int test_attach4;
904 
905   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
906   int test_attach5; ///< \brief\author Aaa
907 
908   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
909   /// \brief\author Aaa
910   int test_attach6(int);
911 };
912 
913 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
914 /// \brief\author Aaa
915 class test_attach7 {
916   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
917   /// \brief\author Aaa
918   int test_attach8;
919 
920   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
921   int test_attach9; ///< \brief\author Aaa
922 
923   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
924   /// \brief\author Aaa
925   int test_attach10(int);
926 };
927 
928 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
929 /// \brief\author Aaa
930 enum test_attach9 {
931   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
932   /// \brief\author Aaa
933   test_attach10,
934 
935   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
936   test_attach11 ///< \brief\author Aaa
937 };
938 
939 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
940 /// \brief\author Aaa
941 struct test_noattach12 *test_attach13;
942 
943 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
944 /// \brief\author Aaa
945 typedef struct test_noattach14 *test_attach15;
946 
947 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}}
948 /// \brief\author Aaa
949 typedef struct test_attach16 { int a; } test_attach17;
950 
951 struct S { int a; };
952 
953 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
954 /// \brief\author Aaa
955 struct S *test_attach18;
956 
957 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
958 /// \brief\author Aaa
959 typedef struct S *test_attach19;
960 
961 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
962 /// \brief\author Aaa
963 struct test_attach20;
964 
965 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}}
966 /// \brief\author Aaa
967 typedef struct test_attach21 {
968   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
969   /// \brief\author Aaa
970   int test_attach22;
971 } test_attach23;
972 
973 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
974 /// \brief\author Aaa
975 namespace test_attach24 {
976   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
977   /// \brief\author Aaa
978   namespace test_attach25 {
979   }
980 }
981 
982 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
983 /// \brief\author Aaa
984 /// \tparam T Aaa
985 template<typename T>
986 void test_attach26(T aaa);
987 
988 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
989 /// \brief\author Aaa
990 /// \tparam T Aaa
991 template<typename T, typename U>
992 void test_attach27(T aaa, U bbb);
993 
994 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
995 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
996 /// \brief\author Aaa
997 /// \tparam T Aaa
998 template<>
999 void test_attach27(int aaa, int bbb);
1000 
1001 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1002 /// \brief\author Aaa
1003 /// \tparam T Aaa
1004 template<typename T>
1005 class test_attach28 {
1006   T aaa;
1007 };
1008 
1009 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1010 /// \brief\author Aaa
1011 using test_attach29 = test_attach28<int>;
1012 
1013 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1014 /// \brief\author Aaa
1015 /// \tparam T Aaa
1016 template<typename T, typename U>
1017 class test_attach30 { };
1018 
1019 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1020 /// \brief\author Aaa
1021 /// \tparam T Aaa
1022 template<typename T>
1023 class test_attach30<T, int> { };
1024 
1025 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1026 /// \brief\author Aaa
1027 template<>
1028 class test_attach30<int, int> { };
1029 
1030 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1031 /// \brief\author Aaa
1032 template<typename T>
1033 using test_attach31 = test_attach30<T, int>;
1034 
1035 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1036 /// \brief\author Aaa
1037 /// \tparam T Aaa
1038 template<typename T, typename U, typename V>
1039 class test_attach32 { };
1040 
1041 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1042 /// \brief\author Aaa
1043 /// \tparam T Aaa
1044 template<typename T, typename U>
1045 class test_attach32<T, U, int> { };
1046 
1047 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1048 /// \brief\author Aaa
1049 /// \tparam T Aaa
1050 template<typename T>
1051 class test_attach32<T, int, int> { };
1052 
1053 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1054 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1055 /// \brief\author Aaa
1056 /// \tparam T Aaa
1057 template<>
1058 class test_attach32<int, int, int> { };
1059 
1060 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1061 /// \brief\author Aaa
1062 class test_attach33 {
1063   // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1064   /// \brief\author Aaa
1065   /// \tparam T Aaa
1066   template<typename T, typename U>
1067   void test_attach34(T aaa, U bbb);
1068 };
1069 
1070 template<typename T>
1071 class test_attach35 {
1072   // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1073   // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1074   /// \brief\author Aaa
1075   /// \tparam T Aaa
1076   template<typename TT, typename UU>
1077   void test_attach36(TT aaa, UU bbb);
1078 };
1079 
1080 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1081 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1082 /// \brief\author Aaa
1083 /// \tparam T Aaa
1084 template<> template<>
test_attach36(int aaa,int bbb)1085 void test_attach35<int>::test_attach36(int aaa, int bbb) {}
1086 
1087 template<typename T>
1088 class test_attach37 {
1089   // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1090   // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
1091   /// \brief\author Aaa
1092   /// \tparam T Aaa
1093   void test_attach38(int aaa, int bbb);
1094 
1095   void test_attach39(int aaa, int bbb);
1096 };
1097 
1098 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1099 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1100 /// \brief\author Aaa
1101 /// \tparam T Aaa
1102 template<>
test_attach38(int aaa,int bbb)1103 void test_attach37<int>::test_attach38(int aaa, int bbb) {}
1104 
1105 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1106 /// \brief\author Aaa
1107 /// \tparam T Aaa
1108 template<typename T>
test_attach39(int aaa,int bbb)1109 void test_attach37<T>::test_attach39(int aaa, int bbb) {}
1110 
1111 // We used to emit warning that parameter 'a' is not found because we parsed
1112 // the comment in context of the redeclaration which does not have parameter
1113 // names.
1114 template <typename T>
1115 struct test_attach38 {
1116   /*!
1117     \param a  First param
1118     \param b  Second param
1119   */
1120   template <typename B>
1121   void test_attach39(T a, B b);
1122 };
1123 
1124 template <>
1125 template <typename B>
1126 void test_attach38<int>::test_attach39(int, B);
1127 
1128 // The inline comments expect a string after the command.
1129 // expected-warning@+1 {{'\a' command has no word arguments, expected 1}}
1130 /// \a
1131 int test_inline_no_argument_a_bad(int);
1132 
1133 /// \a A
1134 int test_inline_no_argument_a_good(int);
1135 
1136 // expected-warning@+1 {{'\anchor' command has no word arguments, expected 1}}
1137 /// \anchor
1138 int test_inline_no_argument_anchor_bad(int);
1139 
1140 /// \anchor A
1141 int test_inline_no_argument_anchor_good(int);
1142 
1143 // expected-warning@+1 {{'@b' command has no word arguments, expected 1}}
1144 /// @b
1145 int test_inline_no_argument_b_bad(int);
1146 
1147 /// @b A
1148 int test_inline_no_argument_b_good(int);
1149 
1150 // expected-warning@+1 {{'\c' command has no word arguments, expected 1}}
1151 /// \c
1152 int test_inline_no_argument_c_bad(int);
1153 
1154 /// \c A
1155 int test_inline_no_argument_c_good(int);
1156 
1157 // expected-warning@+1 {{'\e' command has no word arguments, expected 1}}
1158 /// \e
1159 int test_inline_no_argument_e_bad(int);
1160 
1161 /// \e A
1162 int test_inline_no_argument_e_good(int);
1163 
1164 // expected-warning@+1 {{'\em' command has no word arguments, expected 1}}
1165 /// \em
1166 int test_inline_no_argument_em_bad(int);
1167 
1168 /// \em A
1169 int test_inline_no_argument_em_good(int);
1170 
1171 // expected-warning@+1 {{'\p' command has no word arguments, expected 1}}
1172 /// \p
1173 int test_inline_no_argument_p_bad(int);
1174 
1175 /// \p A
1176 int test_inline_no_argument_p_good(int);
1177 
1178 // PR13411, reduced.  We used to crash on this.
1179 /**
1180  * @code Aaa.
1181  */
1182 void test_nocrash1(int);
1183 
1184 // We used to crash on this.
1185 // expected-warning@+2 {{empty paragraph passed to '\param' command}}
1186 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1187 /// \param\brief
1188 void test_nocrash2(int);
1189 
1190 // PR13593, example 1 and 2
1191 
1192 /**
1193 * Bla.
1194 */
1195 template <typename>
1196 void test_nocrash3();
1197 
1198 /// Foo
1199 template <typename, typename>
test_nocrash4()1200 void test_nocrash4() { }
1201 
1202 template <typename>
test_nocrash3()1203 void test_nocrash3()
1204 {
1205 }
1206 
1207 // PR13593, example 3
1208 
1209 /**
1210  * aaa
1211  */
1212 template <typename T>
test_nocrash5(T a1)1213 inline T test_nocrash5(T a1)
1214 {
1215     return a1;
1216 }
1217 
1218 ///
1219 //,
1220 
test_nocrash6()1221 inline void test_nocrash6()
1222 {
1223     test_nocrash5(1);
1224 }
1225 
1226 // We used to crash on this.
1227 
1228 /*!
1229   Blah.
1230 */
1231 typedef const struct test_nocrash7 * test_nocrash8;
1232 
1233 // We used to crash on this.
1234 
1235 // expected-warning@+1 {{unknown command tag name}}
1236 /// aaa \unknown aaa \unknown aaa
1237 int test_nocrash9;
1238 
1239 // We used to crash on this.  PR15068
1240 
1241 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1242 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1243 ///@param x
1244 ///@param y
1245 int test_nocrash10(int x, int y);
1246 
1247 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
1248 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
1249 ///@param x
1250 ///@param y
1251 int test_nocrash11();
1252 
1253 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
1254 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
1255 /**
1256 @param x
1257 @param y
1258 **/
1259 int test_nocrash12();
1260 
1261 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1262 // expected-warning@+1 {{empty paragraph passed to '@param' command}}
1263 ///@param x@param y
1264 int test_nocrash13(int x, int y);
1265 
1266 /**
1267  * \verbatim
1268  * Aaa
1269  **/
1270 int test_nocrash14();
1271 
1272 // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
1273 /*!
1274    @union U This is new
1275 */
1276 struct U { int iS; };
1277 
1278 /*!
1279   @union U1
1280 */
1281 union U1 {int i; };
1282 
1283 // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
1284 /*!
1285  @struct S2
1286 */
1287 union S2 {};
1288 
1289 /*!
1290   @class C1
1291 */
1292 class C1;
1293 
1294 /*!
1295   @struct S3;
1296 */
1297 class S3;
1298 
1299 //----------------------------------------------------------------------
1300 /// @class Predicate Predicate.h "lldb/Host/Predicate.h"
1301 /// @brief A C++ wrapper class for providing threaded access to a value
1302 /// of type T.
1303 ///
1304 /// A templatized class.
1305 /// specified values.
1306 //----------------------------------------------------------------------
1307 template <class T, class T1>
1308 class Predicate
1309 {
1310 };
1311 
1312 //----------------------------------------------------------------------
1313 /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
1314 /// @brief A C++ wrapper class for providing threaded access to a value
1315 /// of type T.
1316 ///
1317 /// A template specialization class.
1318 //----------------------------------------------------------------------
1319 template<> class Predicate<int, char>
1320 {
1321 };
1322 
1323 //----------------------------------------------------------------------
1324 /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
1325 /// @brief A C++ wrapper class for providing threaded access to a value
1326 /// of type T.
1327 ///
1328 /// A partial specialization template class.
1329 //----------------------------------------------------------------------
1330 template<class T> class Predicate<T, int>
1331 {
1332 };
1333 
1334 /*!     @function test_function
1335 */
1336 template <class T> T test_function (T arg);
1337 
1338 /*!     @function test_function<int>
1339 */
1340 template <> int test_function<int> (int arg);
1341 
1342 namespace AllowParamAndReturnsOnFunctionPointerVars {
1343 
1344 /**
1345  * functionPointerVariable
1346  *
1347  * @param i is integer.
1348  * @returns integer.
1349  */
1350 int (*functionPointerVariable)(int i);
1351 
1352 #if __cplusplus >= 201402L
1353 /**
1354  * functionPointerVariableTemplate
1355  *
1356  * @param i is something.
1357  * @returns integer.
1358  */
1359 template<typename T>
1360 int (*functionPointerVariableTemplate)(T i);
1361 #endif
1362 
1363 struct HasFields {
1364   /**
1365    * functionPointerField
1366    *
1367    * @param i is integer.
1368    * @returns integer.
1369    */
1370   int (*functionPointerField)(int i);
1371 
1372 #if __cplusplus >= 201402L
1373   /**
1374    * functionPointerTemplateMember
1375    *
1376    * @tparam T some type.
1377    * @param i is integer.
1378    * @returns integer.
1379    */
1380   template<typename T>
1381   static int (*functionPointerTemplateMember)(int i);
1382 #endif
1383 };
1384 
1385 // expected-warning@+5 {{parameter 'p' not found in the function declaration}}
1386 // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
1387 /**
1388  * functionPointerVariable
1389  *
1390  * \param p not here.
1391  * \returns integer.
1392  */
1393 void (*functionPointerVariableThatLeadsNowhere)();
1394 
1395 #if __cplusplus >= 201402L
1396 // expected-warning@+8 {{template parameter 'X' not found in the template declaration}}
1397 // expected-note@+7 {{did you mean 'T'?}}
1398 // expected-warning@+7 {{parameter 'p' not found in the function declaration}}
1399 // expected-note@+6 {{did you mean 'x'?}}
1400 // expected-warning@+6 {{'\returns' command used in a comment that is attached to a function returning void}}
1401 /**
1402  * functionPointerVariable
1403  *
1404  * \tparam X typo
1405  * \param p not here.
1406  * \returns integer.
1407  */
1408 template<typename T>
1409 void (*functionPointerVariableTemplateThatLeadsNowhere)(T x);
1410 #endif
1411 
1412 // Still warn about param/returns commands for variables that don't specify
1413 // the type directly:
1414 
1415 /**
1416  * FunctionPointerTypedef
1417  *
1418  * \param i is integer.
1419  * \returns integer.
1420  */
1421 typedef int (*FunctionPointerTypedef)(int i);
1422 
1423 /**
1424  * FunctionPointerTypealias
1425  *
1426  * \param i is integer.
1427  * \returns integer.
1428  */
1429 using FunctionPointerTypealias = int (*)(int i);
1430 
1431 // expected-warning@+5 {{'@param' command used in a comment that is not attached to a function declaration}}
1432 // expected-warning@+5 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
1433 /**
1434  * functionPointerVariable
1435  *
1436  * @param i is integer.
1437  * @returns integer.
1438  */
1439 FunctionPointerTypedef functionPointerTypedefVariable;
1440 
1441 struct HasMoreFields {
1442   // expected-warning@+5 {{'\param' command used in a comment that is not attached to a function declaration}}
1443   // expected-warning@+5 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
1444   /**
1445    * functionPointerTypealiasField
1446    *
1447    * \param i is integer.
1448    * \returns integer.
1449    */
1450   FunctionPointerTypealias functionPointerTypealiasField;
1451 };
1452 
1453 }
1454 
1455 /*!
1456  * Function pointer typedef with variadic params.
1457  *
1458  * @param a
1459  * works
1460  *
1461  * @param ...
1462  * now should work too.
1463  */
1464 typedef void (*VariadicFnType)(int a, ...);
1465 
1466 /*!
1467  * Function pointer type alias with variadic params.
1468  *
1469  * @param a
1470  * works
1471  *
1472  * @param ...
1473  * now should work too.
1474  */
1475 using VariadicFnType2 = void (*)(int a, ...);
1476 
1477 /*!
1478  * Function pointer type variable.
1479  *
1480  * @param a
1481  * works
1482  *
1483  * @param ...
1484  * now should work too.
1485  */
1486 void (*variadicFnVar)(int a, ...);
1487 
1488 // expected-warning@+2 {{empty paragraph passed to '@note' command}}
1489 /**
1490 @note
1491 \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$
1492 \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$
1493  */
1494 class EmptyNoteNoCrash {
1495 };
1496 
1497 namespace PR42844 { // Assertion failures when using typedefed function pointers
1498 typedef void (*AA)();
1499 typedef AA A();
1500 A *a; ///< \return none
1501 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1502 
1503 typedef void B();
1504 B *b; ///< \return none
1505 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1506 
1507 void CC();
1508 typedef void C();
1509 C &c = CC; ///< \return none
1510 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1511 
1512 using DD = void(*)();
1513 using D = DD();
1514 D *d; ///< \return none
1515 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1516 
1517 using E = void();
1518 E *e; ///< \return none
1519 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1520 
1521 void FF();
1522 using F = void();
1523 F &f = FF; ///< \return none
1524 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1525 
1526 } // namespace PR42844
1527