1 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
2 // RUN: %clang_cc1 -std=c++14 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
4 // This file contains lots of corner cases, so ensure that XML we generate is not invalid.
5 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng %s | FileCheck %s -check-prefix=WRONG
6 // WRONG-NOT: CommentXMLInvalid
8 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
9 // expected-warning@+1 {{expected quoted string after equals sign}}
13 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
14 // expected-warning@+1 {{expected quoted string after equals sign}}
18 // expected-warning@+3 {{HTML tag 'a' requires an end tag}}
19 // expected-warning@+2 {{expected quoted string after equals sign}}
20 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
24 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
25 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
29 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
30 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
34 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
35 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
39 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
40 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
44 // expected-warning@+2 {{HTML tag 'a' requires an end tag}}
45 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
49 // expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
50 /** Aaa bbb<img ddd eee
55 // expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
56 /** Aaa bbb<img ddd eee 42%
61 // expected-warning@+1 {{HTML end tag 'br' is forbidden}}
71 /// Aaa bbb<img src="">
74 /// Aaa bbb<img src=""/>
77 /// Aaa bbb<img src="" />
80 /// <blockquote>Meow</blockquote>
81 int test_html_nesting1(int);
83 /// <b><i>Meow</i></b>
84 int test_html_nesting2(int);
88 int test_html_nesting3(int);
92 int test_html_nesting4(int);
94 // expected-warning@+3 {{HTML tag 'b' requires an end tag}}
95 // expected-warning@+2 {{HTML tag 'i' requires an end tag}}
96 // expected-warning@+1 {{HTML end tag does not match any start tag}}
98 int test_html_nesting5(int);
100 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
101 // expected-warning@+1 {{HTML end tag does not match any start tag}}
102 /// <b><i>Meow</b></b>
103 int test_html_nesting6(int);
105 // expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
106 // expected-warning@+1 {{HTML end tag does not match any start tag}}
107 /// <b><i>Meow</b></i>
108 int test_html_nesting7(int);
110 // expected-warning@+1 {{HTML tag 'b' requires an end tag}}
112 int test_html_nesting8(int);
114 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
115 /// \brief\returns Aaa
116 int test_block_command1(int);
118 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
119 /// \brief \returns Aaa
120 int test_block_command2(int);
122 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
125 int test_block_command3(int);
127 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
131 int test_block_command4(int);
133 // There is trailing whitespace on one of the following lines, don't remove it!
134 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
138 int test_block_command5(int);
141 int test_block_command6(int);
143 // We don't recognize comments in double quotes.
144 /// "\brief \returns Aaa"
145 int test_block_command7(int);
147 // But only if they're single-line. (Doxygen treats multi-line quotes inconsistently.)
148 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
151 int test_block_command8(int);
153 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\brief' here}}
159 int test_duplicate_brief1(int);
161 // expected-warning@+5 {{duplicated command '\short'}} expected-note@+1 {{previous command '\short' here}}
167 int test_duplicate_brief2(int);
169 // expected-warning@+5 {{duplicated command '\brief'}} expected-note@+1 {{previous command '\short' (an alias of '\brief') here}}
175 int test_duplicate_brief3(int);
183 int test_multiple_returns1(int);
190 int test_multiple_returns2(int);
197 int test_multiple_returns3(int);
204 int test_multiple_returns4(int);
207 /// expected-warning@+1 {{empty paragraph passed to '\retval' command}}
209 int test_retval_no_paragraph();
211 /// \retval 0 Everything is fine.
212 int test_retval_fine();
215 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
216 /// \param a Blah blah.
217 int test_param1_backslash
;
220 // Check that the diagnostic uses the same command marker as the comment.
221 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
222 /// @param a Blah blah.
225 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
227 /// \param a Blah blah.
228 int test_param2(int a
);
230 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
232 int test_param3(int a
);
234 /// \param a Blah blah.
235 int test_param4(int a
);
237 /// \param [in] a Blah blah.
238 int test_param5(int a
);
240 /// \param [out] a Blah blah.
241 int test_param6(int a
);
243 /// \param [in,out] a Blah blah.
244 int test_param7(int a
);
246 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
247 /// \param [ in ] a Blah blah.
248 int test_param8(int a
);
250 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
251 /// \param [in, out] a Blah blah.
252 int test_param9(int a
);
254 // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
255 /// \param [ junk] a Blah blah.
256 int test_param10(int a
);
258 // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
259 /// \param a Blah blah.
262 // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
263 /// \param A Blah blah.
264 int test_param12(int a
);
266 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
267 /// \param aab Blah blah.
268 int test_param13(int aaa
, int bbb
);
270 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
271 /// \param aaa Blah blah.
272 /// \param aab Blah blah.
273 int test_param14(int aaa
, int bbb
);
275 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
276 /// \param aab Blah blah.
277 int test_param15(int bbb
, int ccc
);
279 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
283 int test_param16(int aaa
, int bbb
);
285 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
289 int test_param17(int aaa
, int bbb
);
291 // expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
295 int test_param18(int aaa
, int bbb
);
298 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
299 /// \param aaa Blah blah.
302 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
303 /// \param aaa Blah blah.
304 int test_param19(int bbb
, int ccc
);
307 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
308 /// \param aab Blah blah.
310 void test_param20(int bbb
, int ccc
);
312 // expected-warning@+3 {{parameter 'a' is already documented}}
313 // expected-note@+1 {{previous documentation}}
316 int test_param21(int a
);
318 // expected-warning@+4 {{parameter 'x2' is already documented}}
319 // expected-note@+2 {{previous documentation}}
323 int test_param22(int x1
, int x2
, int x3
);
325 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
327 /// \retval 0 Blah blah.
328 int test_param23(int a
);
330 /// \param a \ref test_param23 has an empty paragraph, this doesn't.
331 int test_param24(int a
);
334 // Test that we treat typedefs to some non-function types as functions for the
335 // purposes of documentation comment parsing.
339 inline namespace bar
{
341 struct function_wrapper
{};
344 struct not_a_function_wrapper
{};
348 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
352 typedef int test_function_like_typedef1(int aaa
, int ccc
);
354 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
358 typedef int (*test_function_like_typedef2
)(int aaa
, int ccc
);
360 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
364 typedef int (* const test_function_like_typedef3
)(int aaa
, int ccc
);
366 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
370 typedef int (C::*test_function_like_typedef4
)(int aaa
, int ccc
);
372 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
376 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> test_function_like_typedef5
;
378 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
382 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> *test_function_like_typedef6
;
384 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
388 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> &test_function_like_typedef7
;
390 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
394 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> &&test_function_like_typedef8
;
397 typedef int (*test_not_function_like_typedef1
)(int aaa
);
399 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
401 typedef test_not_function_like_typedef1 test_not_function_like_typedef2
;
404 // Check that the diagnostic uses the same command marker as the comment.
405 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
407 typedef unsigned int test_not_function_like_typedef3
;
409 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
411 typedef foo::not_a_function_wrapper
<1> test_not_function_like_typedef4
;
413 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
417 using test_function_like_using1
= int (int aaa
, int ccc
);
419 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
423 using test_function_like_using2
= int (*)(int aaa
, int ccc
);
425 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
429 using test_function_like_using3
= int (* const)(int aaa
, int ccc
);
431 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
435 using test_function_like_using4
= int (C::*)(int aaa
, int ccc
);
437 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
441 using test_function_like_using5
= foo::function_wrapper
<int (int aaa
, int ccc
)>;
443 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
447 using test_function_like_using6
= foo::function_wrapper
<int (int aaa
, int ccc
)> *;
449 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
453 using test_function_like_using7
= foo::function_wrapper
<int (int aaa
, int ccc
)> &;
455 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
459 using test_function_like_using8
= foo::function_wrapper
<int (int aaa
, int ccc
)> &&;
461 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
462 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
467 using test_function_like_using9
= int(T aaa
, int ccc
);
469 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
470 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
475 using test_function_like_using10
= int (*)(T aaa
, int ccc
);
477 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
478 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
483 using test_function_like_using11
= foo::function_wrapper
<int (T aaa
, int ccc
)>;
485 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
486 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
491 using test_function_like_using12
= foo::function_wrapper
<int (T aaa
, int ccc
)> *;
493 using test_not_function_like_using1
= int (*)(int aaa
);
495 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
497 using test_not_function_like_using2
= test_not_function_like_using1
;
499 // Check that the diagnostic uses the same command marker as the comment.
500 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
502 using test_not_function_like_using3
= unsigned int;
504 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
506 using test_not_function_like_using4
= foo::not_a_function_wrapper
<1>;
509 /// \param ... Vararg
510 int test_vararg_param1(int aaa
, ...);
512 /// \param ... Vararg
513 int test_vararg_param2(...);
515 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
516 /// \param ... Vararg
517 int test_vararg_param3(int aaa
);
519 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
520 /// \param ... Vararg
521 int test_vararg_param4();
525 /// \param ... Vararg
527 int test_template_vararg_param1(int aaa
, ...);
529 /// \param ... Vararg
531 int test_template_vararg_param2(...);
533 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
534 /// \param ... Vararg
536 int test_template_vararg_param3(int aaa
);
538 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
539 /// \param ... Vararg
541 int test_template_vararg_param4();
544 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
548 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
550 void test_tparam2(int aaa
);
552 // expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
554 /// \param aaa Blah blah
556 void test_tparam3(T aaa
);
558 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
560 template<typename TT
>
561 void test_tparam4(TT aaa
);
563 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
565 template<typename TT
>
567 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
569 template<typename TTT
>
570 void test_tparam6(TTT aaa
);
575 template<typename T1
, typename T2
>
576 void test_tparam7(T1 aaa
, T2 bbb
);
578 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
579 /// \tparam SomTy Aaa
580 /// \tparam OtherTy Bbb
581 template<typename SomeTy
, typename OtherTy
>
582 void test_tparam8(SomeTy aaa
, OtherTy bbb
);
584 // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
587 template<typename T1
, typename T2
>
588 void test_tparam9(T1 aaa
, T2 bbb
);
592 template<template<typename T
> class TT
>
593 void test_tparam10(TT
<int> aaa
);
598 template<template<template<typename T
> class TT
, class C
> class TTT
>
599 void test_tparam11();
603 void test_tparam12();
605 template<typename T
, typename U
>
606 class test_tparam13
{ };
610 using test_tparam14
= test_tparam13
<T
, int>;
612 // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
615 using test_tparam15
= test_tparam13
<T
, int>;
621 class test_tparam16
{ };
623 typedef test_tparam16
<int> test_tparam17
;
624 typedef test_tparam16
<double> test_tparam18
;
631 typedef test_tparam19
<int> test_tparam20
;
632 typedef test_tparam19
<double> test_tparam21
;
636 class test_tparam19
{ };
640 // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
649 void test_deprecated_1(int a
) __attribute__((deprecated
));
651 #if __cplusplus >= 201402L
654 [[deprecated
]] void test_deprecated_no_warning_std14(int a
);
657 // We don't want \deprecated to warn about empty paragraph. It is fine to use
658 // \deprecated by itself without explanations.
662 void test_deprecated_2(int a
) __attribute__((deprecated
));
666 void test_deprecated_3(int a
) __attribute__((availability(macosx
,introduced
=10.4)));
670 void test_deprecated_4(int a
) __attribute__((unavailable
));
672 // 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}}
675 void test_deprecated_5(int a
);
677 // 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}}
680 void test_deprecated_6(int a
) {
683 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
687 void test_deprecated_7(T aaa
);
690 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
691 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
693 static void test_deprecated_static();
695 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
696 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
698 static auto test_deprecated_static_trailing_return() -> int;
700 #if __cplusplus >= 201402L
701 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
702 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
704 static decltype(auto) test_deprecated_static_decltype_auto() { return 1; }
707 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
708 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
710 void test_deprecated_const() const;
712 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
713 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
715 auto test_deprecated_trailing_return() -> int;
717 #if __cplusplus >= 201402L
718 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
719 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
721 decltype(auto) test_deprecated_decltype_auto() const { return a
; }
729 // expected-note@+2 {{previous command '\headerfile' here}}
730 // expected-warning@+2 {{duplicated command '\headerfile'}}
732 /// \headerfile foo.h
733 int test__headerfile_1(int a
);
737 void test_invariant_1(int a
);
739 // expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
741 void test_invariant_2(int a
);
746 int test_returns_right_decl_1(int);
748 class test_returns_right_decl_2
{
751 int test_returns_right_decl_3(int);
757 int test_returns_right_decl_4(T aaa
);
762 int test_returns_right_decl_4(int aaa
);
766 T
test_returns_right_decl_5(T aaa
);
768 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
770 int test_returns_wrong_decl_1_backslash
;
773 // Check that the diagnostic uses the same command marker as the comment.
774 // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
776 int test_returns_wrong_decl_1_at
;
778 // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
780 int test_returns_wrong_decl_2
;
782 // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
784 int test_returns_wrong_decl_3
;
786 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
788 void test_returns_wrong_decl_4(int);
790 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
793 void test_returns_wrong_decl_5(T aaa
);
795 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
798 void test_returns_wrong_decl_5(int aaa
);
800 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
802 struct test_returns_wrong_decl_6
{ };
804 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
806 class test_returns_wrong_decl_7
{
807 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
809 test_returns_wrong_decl_7();
811 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
813 ~test_returns_wrong_decl_7();
816 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
818 enum test_returns_wrong_decl_8
{
819 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
821 test_returns_wrong_decl_9
824 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
826 namespace test_returns_wrong_decl_10
{ };
829 // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
830 /*! @function test_function
832 typedef unsigned int Base64Flags
;
833 unsigned test_function(Base64Flags inFlags
);
835 // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
836 /*! @callback test_callback
838 typedef unsigned int BaseFlags
;
839 unsigned (*test_callback
)(BaseFlags inFlags
);
841 // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
843 int test_verbatim_1();
845 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
847 int test_verbatim_2();
849 // FIXME: we give a bad diagnostic here because we throw away non-documentation
852 // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
856 int test_verbatim_3();
859 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
860 int test1
; ///< \brief\author Aaa
862 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
863 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
864 int test2
, ///< \brief\author Aaa
865 test3
; ///< \brief\author Aaa
867 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
868 int test4
; ///< \brief
872 class TestRelates
{};
874 /// \relates TestRelates
876 void test_relates_1();
878 /// \related TestRelates
880 void test_relates_2();
882 /// \relatesalso TestRelates
884 void test_relates_3();
886 /// \relatedalso TestRelates
888 void test_relates_4();
891 // Check that we attach the comment to the declaration during parsing in the
892 // following cases. The test is based on the fact that we don't parse
893 // documentation comments that are not attached to anything.
895 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
896 /// \brief\author Aaa
899 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
900 /// \brief\author Aaa
901 int test_attach2(int);
903 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
904 /// \brief\author Aaa
905 struct test_attach3
{
906 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
907 /// \brief\author Aaa
910 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
911 int test_attach5
; ///< \brief\author Aaa
913 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
914 /// \brief\author Aaa
915 int test_attach6(int);
918 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
919 /// \brief\author Aaa
921 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
922 /// \brief\author Aaa
925 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
926 int test_attach9
; ///< \brief\author Aaa
928 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
929 /// \brief\author Aaa
930 int test_attach10(int);
933 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
934 /// \brief\author Aaa
936 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
937 /// \brief\author Aaa
940 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
941 test_attach11
///< \brief\author Aaa
944 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
945 /// \brief\author Aaa
946 struct test_noattach12
*test_attach13
;
948 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
949 /// \brief\author Aaa
950 typedef struct test_noattach14
*test_attach15
;
952 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}}
953 /// \brief\author Aaa
954 typedef struct test_attach16
{ int a
; } test_attach17
;
958 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
959 /// \brief\author Aaa
960 struct S
*test_attach18
;
962 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
963 /// \brief\author Aaa
964 typedef struct S
*test_attach19
;
966 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
967 /// \brief\author Aaa
968 struct test_attach20
;
970 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}}
971 /// \brief\author Aaa
972 typedef struct test_attach21
{
973 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
974 /// \brief\author Aaa
978 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
979 /// \brief\author Aaa
980 namespace test_attach24
{
981 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
982 /// \brief\author Aaa
983 namespace test_attach25
{
987 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
988 /// \brief\author Aaa
991 void test_attach26(T aaa
);
993 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
994 /// \brief\author Aaa
996 template<typename T
, typename U
>
997 void test_attach27(T aaa
, U bbb
);
999 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1000 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1001 /// \brief\author Aaa
1004 void test_attach27(int aaa
, int bbb
);
1006 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1007 /// \brief\author Aaa
1009 template<typename T
>
1010 class test_attach28
{
1014 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1015 /// \brief\author Aaa
1016 using test_attach29
= test_attach28
<int>;
1018 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1019 /// \brief\author Aaa
1021 template<typename T
, typename U
>
1022 class test_attach30
{ };
1024 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1025 /// \brief\author Aaa
1027 template<typename T
>
1028 class test_attach30
<T
, int> { };
1030 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1031 /// \brief\author Aaa
1033 class test_attach30
<int, int> { };
1035 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1036 /// \brief\author Aaa
1037 template<typename T
>
1038 using test_attach31
= test_attach30
<T
, int>;
1040 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1041 /// \brief\author Aaa
1043 template<typename T
, typename U
, typename V
>
1044 class test_attach32
{ };
1046 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1047 /// \brief\author Aaa
1049 template<typename T
, typename U
>
1050 class test_attach32
<T
, U
, int> { };
1052 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1053 /// \brief\author Aaa
1055 template<typename T
>
1056 class test_attach32
<T
, int, int> { };
1058 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1059 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1060 /// \brief\author Aaa
1063 class test_attach32
<int, int, int> { };
1065 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1066 /// \brief\author Aaa
1067 class test_attach33
{
1068 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1069 /// \brief\author Aaa
1071 template<typename T
, typename U
>
1072 void test_attach34(T aaa
, U bbb
);
1075 template<typename T
>
1076 class test_attach35
{
1077 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1078 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1079 /// \brief\author Aaa
1081 template<typename TT
, typename UU
>
1082 void test_attach36(TT aaa
, UU bbb
);
1085 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1086 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1087 /// \brief\author Aaa
1089 template<> template<>
1090 void test_attach35
<int>::test_attach36(int aaa
, int bbb
) {}
1092 template<typename T
>
1093 class test_attach37
{
1094 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1095 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
1096 /// \brief\author Aaa
1098 void test_attach38(int aaa
, int bbb
);
1100 void test_attach39(int aaa
, int bbb
);
1103 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1104 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1105 /// \brief\author Aaa
1108 void test_attach37
<int>::test_attach38(int aaa
, int bbb
) {}
1110 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1111 /// \brief\author Aaa
1113 template<typename T
>
1114 void test_attach37
<T
>::test_attach39(int aaa
, int bbb
) {}
1116 // We used to emit warning that parameter 'a' is not found because we parsed
1117 // the comment in context of the redeclaration which does not have parameter
1119 template <typename T
>
1120 struct test_attach38
{
1122 \param a First param
1123 \param b Second param
1125 template <typename B
>
1126 void test_attach39(T a
, B b
);
1130 template <typename B
>
1131 void test_attach38
<int>::test_attach39(int, B
);
1133 // The inline comments expect a string after the command.
1134 // expected-warning@+1 {{'\a' command has no word arguments, expected 1}}
1136 int test_inline_no_argument_a_bad(int);
1139 int test_inline_no_argument_a_good(int);
1141 // expected-warning@+1 {{'\anchor' command has no word arguments, expected 1}}
1143 int test_inline_no_argument_anchor_bad(int);
1146 int test_inline_no_argument_anchor_good(int);
1148 // expected-warning@+1 {{'@b' command has no word arguments, expected 1}}
1150 int test_inline_no_argument_b_bad(int);
1153 int test_inline_no_argument_b_good(int);
1155 // expected-warning@+1 {{'\c' command has no word arguments, expected 1}}
1157 int test_inline_no_argument_c_bad(int);
1160 int test_inline_no_argument_c_good(int);
1162 // expected-warning@+1 {{'\e' command has no word arguments, expected 1}}
1164 int test_inline_no_argument_e_bad(int);
1167 int test_inline_no_argument_e_good(int);
1169 // expected-warning@+1 {{'\em' command has no word arguments, expected 1}}
1171 int test_inline_no_argument_em_bad(int);
1174 int test_inline_no_argument_em_good(int);
1176 // expected-warning@+1 {{'\p' command has no word arguments, expected 1}}
1178 int test_inline_no_argument_p_bad(int);
1181 int test_inline_no_argument_p_good(int);
1183 // PR13411, reduced. We used to crash on this.
1187 void test_nocrash1(int);
1189 // We used to crash on this.
1190 // expected-warning@+2 {{empty paragraph passed to '\param' command}}
1191 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1193 void test_nocrash2(int);
1195 // PR13593, example 1 and 2
1201 void test_nocrash3();
1204 template <typename
, typename
>
1205 void test_nocrash4() { }
1208 void test_nocrash3()
1212 // PR13593, example 3
1217 template <typename T
>
1218 inline T
test_nocrash5(T a1
)
1226 inline void test_nocrash6()
1231 // We used to crash on this.
1236 typedef const struct test_nocrash7
* test_nocrash8
;
1238 // We used to crash on this.
1240 // expected-warning@+1 {{unknown command tag name}}
1241 /// aaa \unknown aaa \unknown aaa
1244 // We used to crash on this. PR15068
1246 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1247 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1250 int test_nocrash10(int x
, int y
);
1252 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
1253 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
1256 int test_nocrash11();
1258 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
1259 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
1264 int test_nocrash12();
1266 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1267 // expected-warning@+1 {{empty paragraph passed to '@param' command}}
1269 int test_nocrash13(int x
, int y
);
1275 int test_nocrash14();
1278 // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
1280 @union U This is new
1282 struct U
{ int iS
; };
1289 // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
1306 //----------------------------------------------------------------------
1307 /// @class Predicate Predicate.h "lldb/Host/Predicate.h"
1308 /// @brief A C++ wrapper class for providing threaded access to a value
1311 /// A templatized class.
1312 /// specified values.
1313 //----------------------------------------------------------------------
1314 template <class T
, class T1
>
1319 //----------------------------------------------------------------------
1320 /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
1321 /// @brief A C++ wrapper class for providing threaded access to a value
1324 /// A template specialization class.
1325 //----------------------------------------------------------------------
1326 template<> class Predicate
<int, char>
1330 //----------------------------------------------------------------------
1331 /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
1332 /// @brief A C++ wrapper class for providing threaded access to a value
1335 /// A partial specialization template class.
1336 //----------------------------------------------------------------------
1337 template<class T
> class Predicate
<T
, int>
1341 /*! @function test_function
1343 template <class T
> T
test_function (T arg
);
1345 /*! @function test_function<int>
1347 template <> int test_function
<int> (int arg
);
1349 namespace AllowParamAndReturnsOnFunctionPointerVars
{
1352 * functionPointerVariable
1354 * @param i is integer.
1357 int (*functionPointerVariable
)(int i
);
1359 #if __cplusplus >= 201402L
1361 * functionPointerVariableTemplate
1363 * @param i is something.
1366 template<typename T
>
1367 int (*functionPointerVariableTemplate
)(T i
);
1372 * functionPointerField
1374 * @param i is integer.
1377 int (*functionPointerField
)(int i
);
1379 #if __cplusplus >= 201402L
1381 * functionPointerTemplateMember
1383 * @tparam T some type.
1384 * @param i is integer.
1387 template<typename T
>
1388 static int (*functionPointerTemplateMember
)(int i
);
1392 // expected-warning@+5 {{parameter 'p' not found in the function declaration}}
1393 // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
1395 * functionPointerVariable
1397 * \param p not here.
1400 void (*functionPointerVariableThatLeadsNowhere
)();
1402 #if __cplusplus >= 201402L
1403 // expected-warning@+8 {{template parameter 'X' not found in the template declaration}}
1404 // expected-note@+7 {{did you mean 'T'?}}
1405 // expected-warning@+7 {{parameter 'p' not found in the function declaration}}
1406 // expected-note@+6 {{did you mean 'x'?}}
1407 // expected-warning@+6 {{'\returns' command used in a comment that is attached to a function returning void}}
1409 * functionPointerVariable
1412 * \param p not here.
1415 template<typename T
>
1416 void (*functionPointerVariableTemplateThatLeadsNowhere
)(T x
);
1419 // Still warn about param/returns commands for variables that don't specify
1420 // the type directly:
1423 * FunctionPointerTypedef
1425 * \param i is integer.
1428 typedef int (*FunctionPointerTypedef
)(int i
);
1431 * FunctionPointerTypealias
1433 * \param i is integer.
1436 using FunctionPointerTypealias
= int (*)(int i
);
1438 // expected-warning@+5 {{'@param' command used in a comment that is not attached to a function declaration}}
1439 // expected-warning@+5 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
1441 * functionPointerVariable
1443 * @param i is integer.
1446 FunctionPointerTypedef functionPointerTypedefVariable
;
1448 struct HasMoreFields
{
1449 // expected-warning@+5 {{'\param' command used in a comment that is not attached to a function declaration}}
1450 // expected-warning@+5 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
1452 * functionPointerTypealiasField
1454 * \param i is integer.
1457 FunctionPointerTypealias functionPointerTypealiasField
;
1463 * Function pointer typedef with variadic params.
1469 * now should work too.
1471 typedef void (*VariadicFnType
)(int a
, ...);
1474 * Function pointer type alias with variadic params.
1480 * now should work too.
1482 using VariadicFnType2
= void (*)(int a
, ...);
1485 * Function pointer type variable.
1491 * now should work too.
1493 void (*variadicFnVar
)(int a
, ...);
1495 // expected-warning@+2 {{empty paragraph passed to '@note' command}}
1498 \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$
1499 \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$
1501 class EmptyNoteNoCrash
{
1504 namespace PR42844
{ // Assertion failures when using typedefed function pointers
1505 typedef void (*AA
)();
1507 A
*a
; ///< \return none
1508 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1511 B
*b
; ///< \return none
1512 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1516 C
&c
= CC
; ///< \return none
1517 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1519 using DD
= void(*)();
1521 D
*d
; ///< \return none
1522 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1525 E
*e
; ///< \return none
1526 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1530 F
&f
= FF
; ///< \return none
1531 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1533 } // namespace PR42844