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