warn-documentation.cpp revision c98e9130bcddd0258c110d30749edd2284087e3d
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// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\return' here}}
140/// \return Aaa
141///
142/// Bbb
143///
144/// \return Ccc
145int test_duplicate_returns1(int);
146
147// expected-warning@+5 {{duplicated command '\returns'}} expected-note@+1 {{previous command '\returns' here}}
148/// \returns Aaa
149///
150/// Bbb
151///
152/// \returns Ccc
153int test_duplicate_returns2(int);
154
155// expected-warning@+5 {{duplicated command '\result'}} expected-note@+1 {{previous command '\result' here}}
156/// \result Aaa
157///
158/// Bbb
159///
160/// \result Ccc
161int test_duplicate_returns3(int);
162
163// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\returns' (an alias of '\return') here}}
164/// \returns Aaa
165///
166/// Bbb
167///
168/// \return Ccc
169int test_duplicate_returns4(int);
170
171
172// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
173/// \param a Blah blah.
174int test_param1;
175
176// expected-warning@+1 {{empty paragraph passed to '\param' command}}
177/// \param
178/// \param a Blah blah.
179int test_param2(int a);
180
181// expected-warning@+1 {{empty paragraph passed to '\param' command}}
182/// \param a
183int test_param3(int a);
184
185/// \param a Blah blah.
186int test_param4(int a);
187
188/// \param [in] a Blah blah.
189int test_param5(int a);
190
191/// \param [out] a Blah blah.
192int test_param6(int a);
193
194/// \param [in,out] a Blah blah.
195int test_param7(int a);
196
197// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
198/// \param [ in ] a Blah blah.
199int test_param8(int a);
200
201// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
202/// \param [in, out] a Blah blah.
203int test_param9(int a);
204
205// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
206/// \param [ junk] a Blah blah.
207int test_param10(int a);
208
209// expected-warning@+1 {{parameter 'a' not found in the function declaration}}
210/// \param a Blah blah.
211int test_param11();
212
213// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
214/// \param A Blah blah.
215int test_param12(int a);
216
217// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
218/// \param aab Blah blah.
219int test_param13(int aaa, int bbb);
220
221// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
222/// \param aaa Blah blah.
223/// \param aab Blah blah.
224int test_param14(int aaa, int bbb);
225
226// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
227/// \param aab Blah blah.
228int test_param15(int bbb, int ccc);
229
230// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
231/// \param aab Ccc.
232/// \param aaa Aaa.
233/// \param bbb Bbb.
234int test_param16(int aaa, int bbb);
235
236// expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
237/// \param aaa Aaa.
238/// \param aab Ccc.
239/// \param bbb Bbb.
240int test_param17(int aaa, int bbb);
241
242// expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
243/// \param aaa Aaa.
244/// \param bbb Bbb.
245/// \param aab Ccc.
246int test_param18(int aaa, int bbb);
247
248class C {
249  // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
250  /// \param aaa Blah blah.
251  C(int bbb, int ccc);
252
253  // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
254  /// \param aaa Blah blah.
255 int test_param19(int bbb, int ccc);
256};
257
258// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
259/// \param aab Blah blah.
260template<typename T>
261void test_param20(int bbb, int ccc);
262
263// expected-warning@+3 {{parameter 'a' is already documented}}
264// expected-note@+1 {{previous documentation}}
265/// \param a Aaa.
266/// \param a Aaa.
267int test_param21(int a);
268
269// expected-warning@+4 {{parameter 'x2' is already documented}}
270// expected-note@+2 {{previous documentation}}
271/// \param x1 Aaa.
272/// \param x2 Bbb.
273/// \param x2 Ccc.
274int test_param22(int x1, int x2, int x3);
275
276// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
277/// \param aaa Meow.
278/// \param bbb Bbb.
279/// \returns aaa.
280typedef int test_param23(int aaa, int ccc);
281
282// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
283/// \param aaa Meow.
284/// \param bbb Bbb.
285/// \returns aaa.
286typedef int (*test_param24)(int aaa, int ccc);
287
288// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
289/// \param aaa Meow.
290/// \param bbb Bbb.
291/// \returns aaa.
292typedef int (* const test_param25)(int aaa, int ccc);
293
294// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
295/// \param aaa Meow.
296/// \param bbb Bbb.
297/// \returns aaa.
298typedef int (C::*test_param26)(int aaa, int ccc);
299
300typedef int (*test_param27)(int aaa);
301
302// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
303/// \param aaa Meow.
304typedef test_param27 test_param28;
305
306
307// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
308/// \tparam T Aaa
309int test_tparam1;
310
311// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
312/// \tparam T Aaa
313void test_tparam2(int aaa);
314
315// expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
316/// \tparam
317/// \param aaa Blah blah
318template<typename T>
319void test_tparam3(T aaa);
320
321// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
322/// \tparam T Aaa
323template<typename TT>
324void test_tparam4(TT aaa);
325
326// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
327/// \tparam T Aaa
328template<typename TT>
329class test_tparam5 {
330  // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
331  /// \tparam T Aaa
332  template<typename TTT>
333  void test_tparam6(TTT aaa);
334};
335
336/// \tparam T1 Aaa
337/// \tparam T2 Bbb
338template<typename T1, typename T2>
339void test_tparam7(T1 aaa, T2 bbb);
340
341// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
342/// \tparam SomTy Aaa
343/// \tparam OtherTy Bbb
344template<typename SomeTy, typename OtherTy>
345void test_tparam8(SomeTy aaa, OtherTy bbb);
346
347// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
348/// \tparam T1 Aaa
349/// \tparam T1 Bbb
350template<typename T1, typename T2>
351void test_tparam9(T1 aaa, T2 bbb);
352
353/// \tparam T Aaa
354/// \tparam TT Bbb
355template<template<typename T> class TT>
356void test_tparam10(TT<int> aaa);
357
358/// \tparam T Aaa
359/// \tparam TT Bbb
360/// \tparam TTT Ccc
361template<template<template<typename T> class TT, class C> class TTT>
362void test_tparam11();
363
364/// \tparam I Aaa
365template<int I>
366void test_tparam12();
367
368template<typename T, typename U>
369class test_tparam13 { };
370
371/// \tparam T Aaa
372template<typename T>
373using test_tparam14 = test_tparam13<T, int>;
374
375// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
376/// \tparam U Aaa
377template<typename T>
378using test_tparam15 = test_tparam13<T, int>;
379
380// ----
381
382/// \tparam T Aaa
383template<typename T>
384class test_tparam16 { };
385
386typedef test_tparam16<int> test_tparam17;
387typedef test_tparam16<double> test_tparam18;
388
389// ----
390
391template<typename T>
392class test_tparam19;
393
394typedef test_tparam19<int> test_tparam20;
395typedef test_tparam19<double> test_tparam21;
396
397/// \tparam T Aaa
398template<typename T>
399class test_tparam19 { };
400
401// ----
402
403
404/// Aaa
405/// \deprecated Bbb
406void test_deprecated_1(int a) __attribute__((deprecated));
407
408// We don't want \deprecated to warn about empty paragraph.  It is fine to use
409// \deprecated by itself without explanations.
410
411/// Aaa
412/// \deprecated
413void test_deprecated_2(int a) __attribute__((deprecated));
414
415/// Aaa
416/// \deprecated
417void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
418
419/// Aaa
420/// \deprecated
421void test_deprecated_4(int a) __attribute__((unavailable));
422
423// 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}}
424/// Aaa
425/// \deprecated
426void test_deprecated_5(int a);
427
428// 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}}
429/// Aaa
430/// \deprecated
431void test_deprecated_6(int a) {
432}
433
434// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
435/// Aaa
436/// \deprecated
437template<typename T>
438void test_deprecated_7(T aaa);
439
440
441/// \invariant aaa
442void test_invariant_1(int a);
443
444// expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
445/// \invariant
446void test_invariant_2(int a);
447
448
449// no-warning
450/// \returns Aaa
451int test_returns_right_decl_1(int);
452
453class test_returns_right_decl_2 {
454  // no-warning
455  /// \returns Aaa
456  int test_returns_right_decl_3(int);
457};
458
459// no-warning
460/// \returns Aaa
461template<typename T>
462int test_returns_right_decl_4(T aaa);
463
464// no-warning
465/// \returns Aaa
466template<>
467int test_returns_right_decl_4(int aaa);
468
469/// \returns Aaa
470template<typename T>
471T test_returns_right_decl_5(T aaa);
472
473// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
474/// \returns Aaa
475int test_returns_wrong_decl_1;
476
477// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
478/// \return Aaa
479int test_returns_wrong_decl_2;
480
481// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
482/// \result Aaa
483int test_returns_wrong_decl_3;
484
485// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
486/// \returns Aaa
487void test_returns_wrong_decl_4(int);
488
489// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
490/// \returns Aaa
491template<typename T>
492void test_returns_wrong_decl_5(T aaa);
493
494// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
495/// \returns Aaa
496template<>
497void test_returns_wrong_decl_5(int aaa);
498
499// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
500/// \returns Aaa
501struct test_returns_wrong_decl_6 { };
502
503// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
504/// \returns Aaa
505class test_returns_wrong_decl_7 {
506  // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
507  /// \returns Aaa
508  test_returns_wrong_decl_7();
509
510  // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
511  /// \returns Aaa
512  ~test_returns_wrong_decl_7();
513};
514
515// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
516/// \returns Aaa
517enum test_returns_wrong_decl_8 {
518  // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
519  /// \returns Aaa
520  test_returns_wrong_decl_9
521};
522
523// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
524/// \returns Aaa
525namespace test_returns_wrong_decl_10 { };
526
527
528// expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
529/// \endverbatim
530int test_verbatim_1();
531
532// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
533/// \endcode
534int test_verbatim_2();
535
536// FIXME: we give a bad diagnostic here because we throw away non-documentation
537// comments early.
538//
539// expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
540/// \code
541//  foo
542/// \endcode
543int test_verbatim_3();
544
545
546// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
547int test1; ///< \brief\author Aaa
548
549// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
550// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
551int test2, ///< \brief\author Aaa
552    test3; ///< \brief\author Aaa
553
554// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
555int test4; ///< \brief
556           ///< \author Aaa
557
558
559// Check that we attach the comment to the declaration during parsing in the
560// following cases.  The test is based on the fact that we don't parse
561// documentation comments that are not attached to anything.
562
563// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
564/// \brief\author Aaa
565int test_attach1;
566
567// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
568/// \brief\author Aaa
569int test_attach2(int);
570
571// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
572/// \brief\author Aaa
573struct test_attach3 {
574  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
575  /// \brief\author Aaa
576  int test_attach4;
577
578  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
579  int test_attach5; ///< \brief\author Aaa
580
581  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
582  /// \brief\author Aaa
583  int test_attach6(int);
584};
585
586// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
587/// \brief\author Aaa
588class test_attach7 {
589  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
590  /// \brief\author Aaa
591  int test_attach8;
592
593  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
594  int test_attach9; ///< \brief\author Aaa
595
596  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
597  /// \brief\author Aaa
598  int test_attach10(int);
599};
600
601// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
602/// \brief\author Aaa
603enum test_attach9 {
604  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
605  /// \brief\author Aaa
606  test_attach10,
607
608  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
609  test_attach11 ///< \brief\author Aaa
610};
611
612// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
613/// \brief\author Aaa
614struct test_noattach12 *test_attach13;
615
616// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
617/// \brief\author Aaa
618typedef struct test_noattach14 *test_attach15;
619
620// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
621/// \brief\author Aaa
622typedef struct test_attach16 { int a; } test_attach17;
623
624struct S { int a; };
625
626// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
627/// \brief\author Aaa
628struct S *test_attach18;
629
630// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
631/// \brief\author Aaa
632typedef struct S *test_attach19;
633
634// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
635/// \brief\author Aaa
636struct test_attach20;
637
638// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
639/// \brief\author Aaa
640typedef struct test_attach21 {
641  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
642  /// \brief\author Aaa
643  int test_attach22;
644} test_attach23;
645
646// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
647/// \brief\author Aaa
648namespace test_attach24 {
649  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
650  /// \brief\author Aaa
651  namespace test_attach25 {
652  }
653}
654
655// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
656/// \brief\author Aaa
657/// \tparam T Aaa
658template<typename T>
659void test_attach26(T aaa);
660
661// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
662/// \brief\author Aaa
663/// \tparam T Aaa
664template<typename T, typename U>
665void test_attach27(T aaa, U bbb);
666
667// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
668// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
669/// \brief\author Aaa
670/// \tparam T Aaa
671template<>
672void test_attach27(int aaa, int bbb);
673
674// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
675/// \brief\author Aaa
676/// \tparam T Aaa
677template<typename T>
678class test_attach28 {
679  T aaa;
680};
681
682// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
683/// \brief\author Aaa
684using test_attach29 = test_attach28<int>;
685
686// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
687/// \brief\author Aaa
688/// \tparam T Aaa
689template<typename T, typename U>
690class test_attach30 { };
691
692// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
693/// \brief\author Aaa
694/// \tparam T Aaa
695template<typename T>
696class test_attach30<T, int> { };
697
698// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
699/// \brief\author Aaa
700template<>
701class test_attach30<int, int> { };
702
703// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
704/// \brief\author Aaa
705template<typename T>
706using test_attach31 = test_attach30<T, int>;
707
708// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
709/// \brief\author Aaa
710/// \tparam T Aaa
711template<typename T, typename U, typename V>
712class test_attach32 { };
713
714// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
715/// \brief\author Aaa
716/// \tparam T Aaa
717template<typename T, typename U>
718class test_attach32<T, U, int> { };
719
720// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
721/// \brief\author Aaa
722/// \tparam T Aaa
723template<typename T>
724class test_attach32<T, int, int> { };
725
726// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
727// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
728/// \brief\author Aaa
729/// \tparam T Aaa
730template<>
731class test_attach32<int, int, int> { };
732
733// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
734/// \brief\author Aaa
735class test_attach33 {
736  // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
737  /// \brief\author Aaa
738  /// \tparam T Aaa
739  template<typename T, typename U>
740  void test_attach34(T aaa, U bbb);
741};
742
743template<typename T>
744class test_attach35 {
745  // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
746  // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
747  /// \brief\author Aaa
748  /// \tparam T Aaa
749  template<typename TT, typename UU>
750  void test_attach36(TT aaa, UU bbb);
751};
752
753// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
754// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
755/// \brief\author Aaa
756/// \tparam T Aaa
757template<> template<>
758void test_attach35<int>::test_attach36(int aaa, int bbb) {}
759
760template<typename T>
761class test_attach37 {
762  // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
763  // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
764  /// \brief\author Aaa
765  /// \tparam T Aaa
766  void test_attach38(int aaa, int bbb);
767
768  void test_attach39(int aaa, int bbb);
769};
770
771// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
772// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
773/// \brief\author Aaa
774/// \tparam T Aaa
775template<>
776void test_attach37<int>::test_attach38(int aaa, int bbb) {}
777
778// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
779/// \brief\author Aaa
780/// \tparam T Aaa
781template<typename T>
782void test_attach37<T>::test_attach39(int aaa, int bbb) {}
783
784// We used to emit warning that parameter 'a' is not found because we parsed
785// the comment in context of the redeclaration which does not have parameter
786// names.
787template <typename T>
788struct test_attach38 {
789  /*!
790    \param a  First param
791    \param b  Second param
792  */
793  template <typename B>
794  void test_attach39(T a, B b);
795};
796
797template <>
798template <typename B>
799void test_attach38<int>::test_attach39(int, B);
800
801
802// PR13411, reduced.  We used to crash on this.
803/**
804 * @code Aaa.
805 */
806void test_nocrash1(int);
807
808// We used to crash on this.
809// expected-warning@+2 {{empty paragraph passed to '\param' command}}
810// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
811/// \param\brief
812void test_nocrash2(int);
813
814// PR13593, example 1 and 2
815
816/**
817* Bla.
818*/
819template <typename>
820void test_nocrash3();
821
822/// Foo
823template <typename, typename>
824void test_nocrash4() { }
825
826template <typename>
827void test_nocrash3()
828{
829}
830
831// PR13593, example 3
832
833/**
834 * aaa
835 */
836template <typename T>
837inline T test_nocrash5(T a1)
838{
839    return a1;
840}
841
842///
843//,
844
845inline void test_nocrash6()
846{
847    test_nocrash5(1);
848}
849
850// We used to crash on this.
851
852/*!
853  Blah.
854*/
855typedef const struct test_nocrash7 * test_nocrash8;
856
857// We used to crash on this.
858
859/// aaa \unknown aaa \unknown aaa
860int test_nocrash9;
861
862
863// We used to crash on this.  PR15068
864
865// expected-warning@+2 {{empty paragraph passed to '@param' command}}
866// expected-warning@+2 {{empty paragraph passed to '@param' command}}
867///@param x
868///@param y
869int test_nocrash10(int x, int y);
870
871// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
872// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
873///@param x
874///@param y
875int test_nocrash11();
876
877// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
878// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
879/**
880@param x
881@param y
882**/
883int test_nocrash12();
884
885// expected-warning@+2 {{empty paragraph passed to '@param' command}}
886// expected-warning@+1 {{empty paragraph passed to '@param' command}}
887///@param x@param y
888int test_nocrash13(int x, int y);
889
890// rdar://12397511
891
892// expected-note@+2 {{previous command '\headerfile' here}}
893// expected-warning@+2 {{duplicated command '\headerfile'}}
894/// \headerfile ""
895/// \headerfile foo.h
896int test_duplicate_headerfile1(int);
897
898
899// rdar://13066276
900// expected-warning@+1 {{'@return' command used in a comment that is not attached to a function or method declaration}}
901/** @return s */
902struct s* f(void);
903struct s;
904
905// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
906/** \return s */
907struct q* g(void);
908struct q;
909
910