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