1// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
2
3// This file contains lots of corner cases, so ensure that XML we generate is not invalid.
4// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
5// WRONG-NOT: CommentXMLInvalid
6
7// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
8// expected-warning@+1 {{expected quoted string after equals sign}}
9/// <a href=>
10int test_html1(int);
11
12// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
13// expected-warning@+1 {{expected quoted string after equals sign}}
14/// <a href==>
15int test_html2(int);
16
17// expected-warning@+3 {{HTML tag 'a' requires an end tag}}
18// expected-warning@+2 {{expected quoted string after equals sign}}
19// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
20/// <a href= blah
21int test_html3(int);
22
23// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
24// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
25/// <a =>
26int test_html4(int);
27
28// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
29// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
30/// <a "aaa">
31int test_html5(int);
32
33// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
34// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
35/// <a a="b" =>
36int test_html6(int);
37
38// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
39// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
40/// <a a="b" "aaa">
41int test_html7(int);
42
43// expected-warning@+2 {{HTML tag 'a' requires an end tag}}
44// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
45/// <a a="b" =
46int test_html8(int);
47
48// expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
49/** Aaa bbb<img ddd eee
50 * fff ggg.
51 */
52int test_html9(int);
53
54// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
55/** Aaa bbb<img ddd eee 42%
56 * fff ggg.
57 */
58int test_html10(int);
59
60// expected-warning@+1 {{HTML end tag 'br' is forbidden}}
61/// <br></br>
62int test_html11(int);
63
64/// <blockquote>Meow</blockquote>
65int test_html_nesting1(int);
66
67/// <b><i>Meow</i></b>
68int test_html_nesting2(int);
69
70/// <p>Aaa<br>
71/// Bbb</p>
72int test_html_nesting3(int);
73
74/// <p>Aaa<br />
75/// Bbb</p>
76int test_html_nesting4(int);
77
78// expected-warning@+3 {{HTML tag 'b' requires an end tag}}
79// expected-warning@+2 {{HTML tag 'i' requires an end tag}}
80// expected-warning@+1 {{HTML end tag does not match any start tag}}
81/// <b><i>Meow</a>
82int test_html_nesting5(int);
83
84// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
85// expected-warning@+1 {{HTML end tag does not match any start tag}}
86/// <b><i>Meow</b></b>
87int test_html_nesting6(int);
88
89// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
90// expected-warning@+1 {{HTML end tag does not match any start tag}}
91/// <b><i>Meow</b></i>
92int test_html_nesting7(int);
93
94// expected-warning@+1 {{HTML tag 'b' requires an end tag}}
95/// <b>Meow
96int test_html_nesting8(int);
97
98// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
99/// \brief\returns Aaa
100int test_block_command1(int);
101
102// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
103/// \brief \returns Aaa
104int test_block_command2(int);
105
106// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
107/// \brief
108/// \returns Aaa
109int test_block_command3(int);
110
111// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
112/// \brief
113///
114/// \returns Aaa
115int test_block_command4(int);
116
117// There is trailing whitespace on one of the following lines, don't remove it!
118// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
119/// \brief
120///
121/// \returns Aaa
122int test_block_command5(int);
123
124/// \brief \c Aaa
125int test_block_command6(int);
126
127// expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
128/// \brief Aaa
129///
130/// Bbb
131///
132/// \brief Ccc
133int test_duplicate_brief1(int);
134
135// expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
136/// \short Aaa
137///
138/// Bbb
139///
140/// \short Ccc
141int test_duplicate_brief2(int);
142
143// expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
144/// \short Aaa
145///
146/// Bbb
147///
148/// \brief Ccc
149int test_duplicate_brief3(int);
150
151
152/// \return Aaa
153///
154/// Bbb
155///
156/// \return Ccc
157int test_multiple_returns1(int);
158
159/// \returns Aaa
160///
161/// Bbb
162///
163/// \returns Ccc
164int test_multiple_returns2(int);
165
166/// \result Aaa
167///
168/// Bbb
169///
170/// \result Ccc
171int test_multiple_returns3(int);
172
173/// \returns Aaa
174///
175/// Bbb
176///
177/// \return Ccc
178int test_multiple_returns4(int);
179
180
181// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
182/// \param a Blah blah.
183int test_param1_backslash;
184
185// rdar://13066276
186// Check that the diagnostic uses the same command marker as the comment.
187// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
188/// @param a Blah blah.
189int test_param1_at;
190
191// expected-warning@+1 {{empty paragraph passed to '\param' command}}
192/// \param
193/// \param a Blah blah.
194int test_param2(int a);
195
196// expected-warning@+1 {{empty paragraph passed to '\param' command}}
197/// \param a
198int test_param3(int a);
199
200/// \param a Blah blah.
201int test_param4(int a);
202
203/// \param [in] a Blah blah.
204int test_param5(int a);
205
206/// \param [out] a Blah blah.
207int test_param6(int a);
208
209/// \param [in,out] a Blah blah.
210int test_param7(int a);
211
212// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
213/// \param [ in ] a Blah blah.
214int test_param8(int a);
215
216// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
217/// \param [in, out] a Blah blah.
218int test_param9(int a);
219
220// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
221/// \param [ junk] a Blah blah.
222int test_param10(int a);
223
224// expected-warning@+1 {{parameter 'a' not found in the function declaration}}
225/// \param a Blah blah.
226int test_param11();
227
228// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
229/// \param A Blah blah.
230int test_param12(int a);
231
232// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
233/// \param aab Blah blah.
234int test_param13(int aaa, int bbb);
235
236// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
237/// \param aaa Blah blah.
238/// \param aab Blah blah.
239int test_param14(int aaa, int bbb);
240
241// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
242/// \param aab Blah blah.
243int test_param15(int bbb, int ccc);
244
245// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
246/// \param aab Ccc.
247/// \param aaa Aaa.
248/// \param bbb Bbb.
249int test_param16(int aaa, int bbb);
250
251// expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
252/// \param aaa Aaa.
253/// \param aab Ccc.
254/// \param bbb Bbb.
255int test_param17(int aaa, int bbb);
256
257// expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
258/// \param aaa Aaa.
259/// \param bbb Bbb.
260/// \param aab Ccc.
261int test_param18(int aaa, int bbb);
262
263class C {
264  // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
265  /// \param aaa Blah blah.
266  C(int bbb, int ccc);
267
268  // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
269  /// \param aaa Blah blah.
270 int test_param19(int bbb, int ccc);
271};
272
273// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
274/// \param aab Blah blah.
275template<typename T>
276void test_param20(int bbb, int ccc);
277
278// expected-warning@+3 {{parameter 'a' is already documented}}
279// expected-note@+1 {{previous documentation}}
280/// \param a Aaa.
281/// \param a Aaa.
282int test_param21(int a);
283
284// expected-warning@+4 {{parameter 'x2' is already documented}}
285// expected-note@+2 {{previous documentation}}
286/// \param x1 Aaa.
287/// \param x2 Bbb.
288/// \param x2 Ccc.
289int test_param22(int x1, int x2, int x3);
290
291//===---
292// Test that we treat typedefs to some non-function types as functions for the
293// purposes of documentation comment parsing.
294//===---
295
296namespace foo {
297  inline namespace bar {
298    template<typename>
299    struct function_wrapper {};
300
301    template<unsigned>
302    struct not_a_function_wrapper {};
303  }
304};
305
306// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
307/// \param aaa Meow.
308/// \param bbb Bbb.
309/// \returns aaa.
310typedef int test_function_like_typedef1(int aaa, int ccc);
311
312// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
313/// \param aaa Meow.
314/// \param bbb Bbb.
315/// \returns aaa.
316typedef int (*test_function_like_typedef2)(int aaa, int ccc);
317
318// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
319/// \param aaa Meow.
320/// \param bbb Bbb.
321/// \returns aaa.
322typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
323
324// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
325/// \param aaa Meow.
326/// \param bbb Bbb.
327/// \returns aaa.
328typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
329
330// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
331/// \param aaa Meow.
332/// \param bbb Bbb.
333/// \returns aaa.
334typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
335
336// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
337/// \param aaa Meow.
338/// \param bbb Bbb.
339/// \returns aaa.
340typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
341
342// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
343/// \param aaa Meow.
344/// \param bbb Bbb.
345/// \returns aaa.
346typedef foo::function_wrapper<int (int aaa, int ccc)> &test_function_like_typedef7;
347
348// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
349/// \param aaa Meow.
350/// \param bbb Bbb.
351/// \returns aaa.
352typedef foo::function_wrapper<int (int aaa, int ccc)> &&test_function_like_typedef8;
353
354
355typedef int (*test_not_function_like_typedef1)(int aaa);
356
357// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
358/// \param aaa Meow.
359typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
360
361// rdar://13066276
362// Check that the diagnostic uses the same command marker as the comment.
363// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
364/// @param aaa Meow.
365typedef unsigned int test_not_function_like_typedef3;
366
367// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
368/// \param aaa Meow.
369typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
370
371/// \param aaa Aaa
372/// \param ... Vararg
373int test_vararg_param1(int aaa, ...);
374
375/// \param ... Vararg
376int test_vararg_param2(...);
377
378// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
379/// \param ... Vararg
380int test_vararg_param3(int aaa);
381
382// expected-warning@+1 {{parameter '...' not found in the function declaration}}
383/// \param ... Vararg
384int test_vararg_param4();
385
386
387/// \param aaa Aaa
388/// \param ... Vararg
389template<typename T>
390int test_template_vararg_param1(int aaa, ...);
391
392/// \param ... Vararg
393template<typename T>
394int test_template_vararg_param2(...);
395
396// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
397/// \param ... Vararg
398template<typename T>
399int test_template_vararg_param3(int aaa);
400
401// expected-warning@+1 {{parameter '...' not found in the function declaration}}
402/// \param ... Vararg
403template<typename T>
404int test_template_vararg_param4();
405
406
407// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
408/// \tparam T Aaa
409int test_tparam1;
410
411// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
412/// \tparam T Aaa
413void test_tparam2(int aaa);
414
415// expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
416/// \tparam
417/// \param aaa Blah blah
418template<typename T>
419void test_tparam3(T aaa);
420
421// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
422/// \tparam T Aaa
423template<typename TT>
424void test_tparam4(TT aaa);
425
426// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
427/// \tparam T Aaa
428template<typename TT>
429class test_tparam5 {
430  // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
431  /// \tparam T Aaa
432  template<typename TTT>
433  void test_tparam6(TTT aaa);
434};
435
436/// \tparam T1 Aaa
437/// \tparam T2 Bbb
438template<typename T1, typename T2>
439void test_tparam7(T1 aaa, T2 bbb);
440
441// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
442/// \tparam SomTy Aaa
443/// \tparam OtherTy Bbb
444template<typename SomeTy, typename OtherTy>
445void test_tparam8(SomeTy aaa, OtherTy bbb);
446
447// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
448/// \tparam T1 Aaa
449/// \tparam T1 Bbb
450template<typename T1, typename T2>
451void test_tparam9(T1 aaa, T2 bbb);
452
453/// \tparam T Aaa
454/// \tparam TT Bbb
455template<template<typename T> class TT>
456void test_tparam10(TT<int> aaa);
457
458/// \tparam T Aaa
459/// \tparam TT Bbb
460/// \tparam TTT Ccc
461template<template<template<typename T> class TT, class C> class TTT>
462void test_tparam11();
463
464/// \tparam I Aaa
465template<int I>
466void test_tparam12();
467
468template<typename T, typename U>
469class test_tparam13 { };
470
471/// \tparam T Aaa
472template<typename T>
473using test_tparam14 = test_tparam13<T, int>;
474
475// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
476/// \tparam U Aaa
477template<typename T>
478using test_tparam15 = test_tparam13<T, int>;
479
480// ----
481
482/// \tparam T Aaa
483template<typename T>
484class test_tparam16 { };
485
486typedef test_tparam16<int> test_tparam17;
487typedef test_tparam16<double> test_tparam18;
488
489// ----
490
491template<typename T>
492class test_tparam19;
493
494typedef test_tparam19<int> test_tparam20;
495typedef test_tparam19<double> test_tparam21;
496
497/// \tparam T Aaa
498template<typename T>
499class test_tparam19 { };
500
501// ----
502
503// expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
504/// @tparam T Aaa
505int test_tparam22;
506
507// ----
508
509
510/// Aaa
511/// \deprecated Bbb
512void test_deprecated_1(int a) __attribute__((deprecated));
513
514// We don't want \deprecated to warn about empty paragraph.  It is fine to use
515// \deprecated by itself without explanations.
516
517/// Aaa
518/// \deprecated
519void test_deprecated_2(int a) __attribute__((deprecated));
520
521/// Aaa
522/// \deprecated
523void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
524
525/// Aaa
526/// \deprecated
527void test_deprecated_4(int a) __attribute__((unavailable));
528
529// 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}}
530/// Aaa
531/// \deprecated
532void test_deprecated_5(int a);
533
534// 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}}
535/// Aaa
536/// \deprecated
537void test_deprecated_6(int a) {
538}
539
540// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
541/// Aaa
542/// \deprecated
543template<typename T>
544void test_deprecated_7(T aaa);
545
546
547// rdar://12397511
548// expected-note@+2 {{previous command '\headerfile' here}}
549// expected-warning@+2 {{duplicated command '\headerfile'}}
550/// \headerfile ""
551/// \headerfile foo.h
552int test__headerfile_1(int a);
553
554
555/// \invariant aaa
556void test_invariant_1(int a);
557
558// expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
559/// \invariant
560void test_invariant_2(int a);
561
562
563// no-warning
564/// \returns Aaa
565int test_returns_right_decl_1(int);
566
567class test_returns_right_decl_2 {
568  // no-warning
569  /// \returns Aaa
570  int test_returns_right_decl_3(int);
571};
572
573// no-warning
574/// \returns Aaa
575template<typename T>
576int test_returns_right_decl_4(T aaa);
577
578// no-warning
579/// \returns Aaa
580template<>
581int test_returns_right_decl_4(int aaa);
582
583/// \returns Aaa
584template<typename T>
585T test_returns_right_decl_5(T aaa);
586
587// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
588/// \returns Aaa
589int test_returns_wrong_decl_1_backslash;
590
591// rdar://13066276
592// Check that the diagnostic uses the same command marker as the comment.
593// expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
594/// @returns Aaa
595int test_returns_wrong_decl_1_at;
596
597// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
598/// \return Aaa
599int test_returns_wrong_decl_2;
600
601// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
602/// \result Aaa
603int test_returns_wrong_decl_3;
604
605// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
606/// \returns Aaa
607void test_returns_wrong_decl_4(int);
608
609// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
610/// \returns Aaa
611template<typename T>
612void test_returns_wrong_decl_5(T aaa);
613
614// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
615/// \returns Aaa
616template<>
617void test_returns_wrong_decl_5(int aaa);
618
619// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
620/// \returns Aaa
621struct test_returns_wrong_decl_6 { };
622
623// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
624/// \returns Aaa
625class test_returns_wrong_decl_7 {
626  // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
627  /// \returns Aaa
628  test_returns_wrong_decl_7();
629
630  // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
631  /// \returns Aaa
632  ~test_returns_wrong_decl_7();
633};
634
635// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
636/// \returns Aaa
637enum test_returns_wrong_decl_8 {
638  // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
639  /// \returns Aaa
640  test_returns_wrong_decl_9
641};
642
643// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
644/// \returns Aaa
645namespace test_returns_wrong_decl_10 { };
646
647// rdar://13094352
648// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
649/*!	@function test_function
650*/
651typedef unsigned int Base64Flags;
652unsigned test_function(Base64Flags inFlags);
653
654// expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
655/*! @callback test_callback
656*/
657typedef unsigned int BaseFlags;
658unsigned (*test_callback)(BaseFlags inFlags);
659
660// expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
661/// \endverbatim
662int test_verbatim_1();
663
664// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
665/// \endcode
666int test_verbatim_2();
667
668// FIXME: we give a bad diagnostic here because we throw away non-documentation
669// comments early.
670//
671// expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
672/// \code
673//  foo
674/// \endcode
675int test_verbatim_3();
676
677
678// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
679int test1; ///< \brief\author Aaa
680
681// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
682// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
683int test2, ///< \brief\author Aaa
684    test3; ///< \brief\author Aaa
685
686// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
687int test4; ///< \brief
688           ///< \author Aaa
689
690
691class TestRelates {};
692
693/// \relates TestRelates
694/// \brief Aaa
695void test_relates_1();
696
697/// \related TestRelates
698/// \brief Aaa
699void test_relates_2();
700
701/// \relatesalso TestRelates
702/// \brief Aaa
703void test_relates_3();
704
705/// \relatedalso TestRelates
706/// \brief Aaa
707void test_relates_4();
708
709
710// Check that we attach the comment to the declaration during parsing in the
711// following cases.  The test is based on the fact that we don't parse
712// documentation comments that are not attached to anything.
713
714// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
715/// \brief\author Aaa
716int test_attach1;
717
718// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
719/// \brief\author Aaa
720int test_attach2(int);
721
722// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
723/// \brief\author Aaa
724struct test_attach3 {
725  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
726  /// \brief\author Aaa
727  int test_attach4;
728
729  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
730  int test_attach5; ///< \brief\author Aaa
731
732  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
733  /// \brief\author Aaa
734  int test_attach6(int);
735};
736
737// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
738/// \brief\author Aaa
739class test_attach7 {
740  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
741  /// \brief\author Aaa
742  int test_attach8;
743
744  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
745  int test_attach9; ///< \brief\author Aaa
746
747  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
748  /// \brief\author Aaa
749  int test_attach10(int);
750};
751
752// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
753/// \brief\author Aaa
754enum test_attach9 {
755  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
756  /// \brief\author Aaa
757  test_attach10,
758
759  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
760  test_attach11 ///< \brief\author Aaa
761};
762
763// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
764/// \brief\author Aaa
765struct test_noattach12 *test_attach13;
766
767// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
768/// \brief\author Aaa
769typedef struct test_noattach14 *test_attach15;
770
771// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
772/// \brief\author Aaa
773typedef struct test_attach16 { int a; } test_attach17;
774
775struct S { int a; };
776
777// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
778/// \brief\author Aaa
779struct S *test_attach18;
780
781// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
782/// \brief\author Aaa
783typedef struct S *test_attach19;
784
785// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
786/// \brief\author Aaa
787struct test_attach20;
788
789// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
790/// \brief\author Aaa
791typedef struct test_attach21 {
792  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
793  /// \brief\author Aaa
794  int test_attach22;
795} test_attach23;
796
797// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
798/// \brief\author Aaa
799namespace test_attach24 {
800  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
801  /// \brief\author Aaa
802  namespace test_attach25 {
803  }
804}
805
806// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
807/// \brief\author Aaa
808/// \tparam T Aaa
809template<typename T>
810void test_attach26(T aaa);
811
812// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
813/// \brief\author Aaa
814/// \tparam T Aaa
815template<typename T, typename U>
816void test_attach27(T aaa, U bbb);
817
818// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
819// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
820/// \brief\author Aaa
821/// \tparam T Aaa
822template<>
823void test_attach27(int aaa, int bbb);
824
825// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
826/// \brief\author Aaa
827/// \tparam T Aaa
828template<typename T>
829class test_attach28 {
830  T aaa;
831};
832
833// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
834/// \brief\author Aaa
835using test_attach29 = test_attach28<int>;
836
837// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
838/// \brief\author Aaa
839/// \tparam T Aaa
840template<typename T, typename U>
841class test_attach30 { };
842
843// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
844/// \brief\author Aaa
845/// \tparam T Aaa
846template<typename T>
847class test_attach30<T, int> { };
848
849// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
850/// \brief\author Aaa
851template<>
852class test_attach30<int, int> { };
853
854// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
855/// \brief\author Aaa
856template<typename T>
857using test_attach31 = test_attach30<T, int>;
858
859// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
860/// \brief\author Aaa
861/// \tparam T Aaa
862template<typename T, typename U, typename V>
863class test_attach32 { };
864
865// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
866/// \brief\author Aaa
867/// \tparam T Aaa
868template<typename T, typename U>
869class test_attach32<T, U, int> { };
870
871// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
872/// \brief\author Aaa
873/// \tparam T Aaa
874template<typename T>
875class test_attach32<T, int, int> { };
876
877// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
878// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
879/// \brief\author Aaa
880/// \tparam T Aaa
881template<>
882class test_attach32<int, int, int> { };
883
884// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
885/// \brief\author Aaa
886class test_attach33 {
887  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
888  /// \brief\author Aaa
889  /// \tparam T Aaa
890  template<typename T, typename U>
891  void test_attach34(T aaa, U bbb);
892};
893
894template<typename T>
895class test_attach35 {
896  // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
897  // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
898  /// \brief\author Aaa
899  /// \tparam T Aaa
900  template<typename TT, typename UU>
901  void test_attach36(TT aaa, UU bbb);
902};
903
904// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
905// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
906/// \brief\author Aaa
907/// \tparam T Aaa
908template<> template<>
909void test_attach35<int>::test_attach36(int aaa, int bbb) {}
910
911template<typename T>
912class test_attach37 {
913  // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
914  // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
915  /// \brief\author Aaa
916  /// \tparam T Aaa
917  void test_attach38(int aaa, int bbb);
918
919  void test_attach39(int aaa, int bbb);
920};
921
922// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
923// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
924/// \brief\author Aaa
925/// \tparam T Aaa
926template<>
927void test_attach37<int>::test_attach38(int aaa, int bbb) {}
928
929// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
930/// \brief\author Aaa
931/// \tparam T Aaa
932template<typename T>
933void test_attach37<T>::test_attach39(int aaa, int bbb) {}
934
935// We used to emit warning that parameter 'a' is not found because we parsed
936// the comment in context of the redeclaration which does not have parameter
937// names.
938template <typename T>
939struct test_attach38 {
940  /*!
941    \param a  First param
942    \param b  Second param
943  */
944  template <typename B>
945  void test_attach39(T a, B b);
946};
947
948template <>
949template <typename B>
950void test_attach38<int>::test_attach39(int, B);
951
952
953// PR13411, reduced.  We used to crash on this.
954/**
955 * @code Aaa.
956 */
957void test_nocrash1(int);
958
959// We used to crash on this.
960// expected-warning@+2 {{empty paragraph passed to '\param' command}}
961// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
962/// \param\brief
963void test_nocrash2(int);
964
965// PR13593, example 1 and 2
966
967/**
968* Bla.
969*/
970template <typename>
971void test_nocrash3();
972
973/// Foo
974template <typename, typename>
975void test_nocrash4() { }
976
977template <typename>
978void test_nocrash3()
979{
980}
981
982// PR13593, example 3
983
984/**
985 * aaa
986 */
987template <typename T>
988inline T test_nocrash5(T a1)
989{
990    return a1;
991}
992
993///
994//,
995
996inline void test_nocrash6()
997{
998    test_nocrash5(1);
999}
1000
1001// We used to crash on this.
1002
1003/*!
1004  Blah.
1005*/
1006typedef const struct test_nocrash7 * test_nocrash8;
1007
1008// We used to crash on this.
1009
1010// expected-warning@+1 {{unknown command tag name}}
1011/// aaa \unknown aaa \unknown aaa
1012int test_nocrash9;
1013
1014// We used to crash on this.  PR15068
1015
1016// expected-warning@+2 {{empty paragraph passed to '@param' command}}
1017// expected-warning@+2 {{empty paragraph passed to '@param' command}}
1018///@param x
1019///@param y
1020int test_nocrash10(int x, int y);
1021
1022// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
1023// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
1024///@param x
1025///@param y
1026int test_nocrash11();
1027
1028// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
1029// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
1030/**
1031@param x
1032@param y
1033**/
1034int test_nocrash12();
1035
1036// expected-warning@+2 {{empty paragraph passed to '@param' command}}
1037// expected-warning@+1 {{empty paragraph passed to '@param' command}}
1038///@param x@param y
1039int test_nocrash13(int x, int y);
1040
1041/**
1042 * \verbatim
1043 * Aaa
1044 **/
1045int test_nocrash14();
1046
1047// rdar://12379114
1048// expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
1049/*!
1050   @union U This is new
1051*/
1052struct U { int iS; };
1053
1054/*!
1055  @union U1
1056*/
1057union U1 {int i; };
1058
1059// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
1060/*!
1061 @struct S2
1062*/
1063union S2 {};
1064
1065/*!
1066  @class C1
1067*/
1068class C1;
1069
1070/*!
1071  @struct S3;
1072*/
1073class S3;
1074
1075// rdar://14124702
1076//----------------------------------------------------------------------
1077/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
1078/// @brief A C++ wrapper class for providing threaded access to a value
1079/// of type T.
1080///
1081/// A templatized class.
1082/// specified values.
1083//----------------------------------------------------------------------
1084template <class T, class T1>
1085class Predicate
1086{
1087};
1088
1089//----------------------------------------------------------------------
1090/// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
1091/// @brief A C++ wrapper class for providing threaded access to a value
1092/// of type T.
1093///
1094/// A template specilization class.
1095//----------------------------------------------------------------------
1096template<> class Predicate<int, char>
1097{
1098};
1099
1100//----------------------------------------------------------------------
1101/// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
1102/// @brief A C++ wrapper class for providing threaded access to a value
1103/// of type T.
1104///
1105/// A partial specialization template class.
1106//----------------------------------------------------------------------
1107template<class T> class Predicate<T, int>
1108{
1109};
1110
1111/*!     @function test_function
1112*/
1113template <class T> T test_function (T arg);
1114
1115/*!     @function test_function<int>
1116*/
1117template <> int test_function<int> (int arg);
1118