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