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
;
219 // Check that the diagnostic uses the same command marker as the comment.
220 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
221 /// @param a Blah blah.
224 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
226 /// \param a Blah blah.
227 int test_param2(int a
);
229 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
231 int test_param3(int a
);
233 /// \param a Blah blah.
234 int test_param4(int a
);
236 /// \param [in] a Blah blah.
237 int test_param5(int a
);
239 /// \param [out] a Blah blah.
240 int test_param6(int a
);
242 /// \param [in,out] a Blah blah.
243 int test_param7(int a
);
245 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
246 /// \param [ in ] a Blah blah.
247 int test_param8(int a
);
249 // expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
250 /// \param [in, out] a Blah blah.
251 int test_param9(int a
);
253 // expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
254 /// \param [ junk] a Blah blah.
255 int test_param10(int a
);
257 // expected-warning@+1 {{parameter 'a' not found in the function declaration}}
258 /// \param a Blah blah.
261 // expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
262 /// \param A Blah blah.
263 int test_param12(int a
);
265 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
266 /// \param aab Blah blah.
267 int test_param13(int aaa
, int bbb
);
269 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
270 /// \param aaa Blah blah.
271 /// \param aab Blah blah.
272 int test_param14(int aaa
, int bbb
);
274 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
275 /// \param aab Blah blah.
276 int test_param15(int bbb
, int ccc
);
278 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
282 int test_param16(int aaa
, int bbb
);
284 // expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
288 int test_param17(int aaa
, int bbb
);
290 // expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
294 int test_param18(int aaa
, int bbb
);
297 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
298 /// \param aaa Blah blah.
301 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
302 /// \param aaa Blah blah.
303 int test_param19(int bbb
, int ccc
);
306 // expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
307 /// \param aab Blah blah.
309 void test_param20(int bbb
, int ccc
);
311 // expected-warning@+3 {{parameter 'a' is already documented}}
312 // expected-note@+1 {{previous documentation}}
315 int test_param21(int a
);
317 // expected-warning@+4 {{parameter 'x2' is already documented}}
318 // expected-note@+2 {{previous documentation}}
322 int test_param22(int x1
, int x2
, int x3
);
324 // expected-warning@+1 {{empty paragraph passed to '\param' command}}
326 /// \retval 0 Blah blah.
327 int test_param23(int a
);
329 /// \param a \ref test_param23 has an empty paragraph, this doesn't.
330 int test_param24(int a
);
333 // Test that we treat typedefs to some non-function types as functions for the
334 // purposes of documentation comment parsing.
338 inline namespace bar
{
340 struct function_wrapper
{};
343 struct not_a_function_wrapper
{};
347 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
351 typedef int test_function_like_typedef1(int aaa
, int ccc
);
353 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
357 typedef int (*test_function_like_typedef2
)(int aaa
, int ccc
);
359 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
363 typedef int (* const test_function_like_typedef3
)(int aaa
, int ccc
);
365 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
369 typedef int (C::*test_function_like_typedef4
)(int aaa
, int ccc
);
371 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
375 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> test_function_like_typedef5
;
377 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
381 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> *test_function_like_typedef6
;
383 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
387 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> &test_function_like_typedef7
;
389 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
393 typedef foo::function_wrapper
<int (int aaa
, int ccc
)> &&test_function_like_typedef8
;
396 typedef int (*test_not_function_like_typedef1
)(int aaa
);
398 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
400 typedef test_not_function_like_typedef1 test_not_function_like_typedef2
;
402 // Check that the diagnostic uses the same command marker as the comment.
403 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
405 typedef unsigned int test_not_function_like_typedef3
;
407 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
409 typedef foo::not_a_function_wrapper
<1> test_not_function_like_typedef4
;
411 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
415 using test_function_like_using1
= int (int aaa
, int ccc
);
417 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
421 using test_function_like_using2
= int (*)(int aaa
, int ccc
);
423 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
427 using test_function_like_using3
= int (* const)(int aaa
, int ccc
);
429 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
433 using test_function_like_using4
= int (C::*)(int aaa
, int ccc
);
435 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
439 using test_function_like_using5
= foo::function_wrapper
<int (int aaa
, int ccc
)>;
441 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
445 using test_function_like_using6
= foo::function_wrapper
<int (int aaa
, int ccc
)> *;
447 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
451 using test_function_like_using7
= foo::function_wrapper
<int (int aaa
, int ccc
)> &;
453 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
457 using test_function_like_using8
= foo::function_wrapper
<int (int aaa
, int ccc
)> &&;
459 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
460 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
465 using test_function_like_using9
= int(T aaa
, int ccc
);
467 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
468 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
473 using test_function_like_using10
= int (*)(T aaa
, int ccc
);
475 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
476 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
481 using test_function_like_using11
= foo::function_wrapper
<int (T aaa
, int ccc
)>;
483 // expected-warning@+4 {{template parameter 'U' not found in the template declaration}} expected-note@+4 {{did you mean 'T'?}}
484 // expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
489 using test_function_like_using12
= foo::function_wrapper
<int (T aaa
, int ccc
)> *;
491 using test_not_function_like_using1
= int (*)(int aaa
);
493 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
495 using test_not_function_like_using2
= test_not_function_like_using1
;
497 // Check that the diagnostic uses the same command marker as the comment.
498 // expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
500 using test_not_function_like_using3
= unsigned int;
502 // expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
504 using test_not_function_like_using4
= foo::not_a_function_wrapper
<1>;
507 /// \param ... Vararg
508 int test_vararg_param1(int aaa
, ...);
510 /// \param ... Vararg
511 int test_vararg_param2(...);
513 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
514 /// \param ... Vararg
515 int test_vararg_param3(int aaa
);
517 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
518 /// \param ... Vararg
519 int test_vararg_param4();
523 /// \param ... Vararg
525 int test_template_vararg_param1(int aaa
, ...);
527 /// \param ... Vararg
529 int test_template_vararg_param2(...);
531 // expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
532 /// \param ... Vararg
534 int test_template_vararg_param3(int aaa
);
536 // expected-warning@+1 {{parameter '...' not found in the function declaration}}
537 /// \param ... Vararg
539 int test_template_vararg_param4();
542 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
546 // expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
548 void test_tparam2(int aaa
);
550 // expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
552 /// \param aaa Blah blah
554 void test_tparam3(T aaa
);
556 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
558 template<typename TT
>
559 void test_tparam4(TT aaa
);
561 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
563 template<typename TT
>
565 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
567 template<typename TTT
>
568 void test_tparam6(TTT aaa
);
573 template<typename T1
, typename T2
>
574 void test_tparam7(T1 aaa
, T2 bbb
);
576 // expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
577 /// \tparam SomTy Aaa
578 /// \tparam OtherTy Bbb
579 template<typename SomeTy
, typename OtherTy
>
580 void test_tparam8(SomeTy aaa
, OtherTy bbb
);
582 // expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
585 template<typename T1
, typename T2
>
586 void test_tparam9(T1 aaa
, T2 bbb
);
590 template<template<typename T
> class TT
>
591 void test_tparam10(TT
<int> aaa
);
596 template<template<template<typename T
> class TT
, class C
> class TTT
>
597 void test_tparam11();
601 void test_tparam12();
603 template<typename T
, typename U
>
604 class test_tparam13
{ };
608 using test_tparam14
= test_tparam13
<T
, int>;
610 // expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
613 using test_tparam15
= test_tparam13
<T
, int>;
619 class test_tparam16
{ };
621 typedef test_tparam16
<int> test_tparam17
;
622 typedef test_tparam16
<double> test_tparam18
;
629 typedef test_tparam19
<int> test_tparam20
;
630 typedef test_tparam19
<double> test_tparam21
;
634 class test_tparam19
{ };
638 // expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
647 void test_deprecated_1(int a
) __attribute__((deprecated
));
649 #if __cplusplus >= 201402L
652 [[deprecated
]] void test_deprecated_no_warning_std14(int a
);
655 // We don't want \deprecated to warn about empty paragraph. It is fine to use
656 // \deprecated by itself without explanations.
660 void test_deprecated_2(int a
) __attribute__((deprecated
));
664 void test_deprecated_3(int a
) __attribute__((availability(macosx
,introduced
=10.4)));
668 void test_deprecated_4(int a
) __attribute__((unavailable
));
670 // 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}}
673 void test_deprecated_5(int a
);
675 // 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}}
678 void test_deprecated_6(int a
) {
681 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
685 void test_deprecated_7(T aaa
);
688 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
689 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
691 static void test_deprecated_static();
693 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
694 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
696 static auto test_deprecated_static_trailing_return() -> int;
698 #if __cplusplus >= 201402L
699 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
700 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
702 static decltype(auto) test_deprecated_static_decltype_auto() { return 1; }
705 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
706 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
708 void test_deprecated_const() const;
710 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
711 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
713 auto test_deprecated_trailing_return() -> int;
715 #if __cplusplus >= 201402L
716 // expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
717 // expected-note@+2 {{add a deprecation attribute to the declaration to silence this warning}}
719 decltype(auto) test_deprecated_decltype_auto() const { return a
; }
726 // expected-note@+2 {{previous command '\headerfile' here}}
727 // expected-warning@+2 {{duplicated command '\headerfile'}}
729 /// \headerfile foo.h
730 int test__headerfile_1(int a
);
734 void test_invariant_1(int a
);
736 // expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
738 void test_invariant_2(int a
);
743 int test_returns_right_decl_1(int);
745 class test_returns_right_decl_2
{
748 int test_returns_right_decl_3(int);
754 int test_returns_right_decl_4(T aaa
);
759 int test_returns_right_decl_4(int aaa
);
763 T
test_returns_right_decl_5(T aaa
);
765 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
767 int test_returns_wrong_decl_1_backslash
;
769 // Check that the diagnostic uses the same command marker as the comment.
770 // expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
772 int test_returns_wrong_decl_1_at
;
774 // expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
776 int test_returns_wrong_decl_2
;
778 // expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
780 int test_returns_wrong_decl_3
;
782 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
784 void test_returns_wrong_decl_4(int);
786 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
789 void test_returns_wrong_decl_5(T aaa
);
791 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
794 void test_returns_wrong_decl_5(int aaa
);
796 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
798 struct test_returns_wrong_decl_6
{ };
800 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
802 class test_returns_wrong_decl_7
{
803 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
805 test_returns_wrong_decl_7();
807 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
809 ~test_returns_wrong_decl_7();
812 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
814 enum test_returns_wrong_decl_8
{
815 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
817 test_returns_wrong_decl_9
820 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
822 namespace test_returns_wrong_decl_10
{ };
824 // expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
825 /*! @function test_function
827 typedef unsigned int Base64Flags
;
828 unsigned test_function(Base64Flags inFlags
);
830 // expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
831 /*! @callback test_callback
833 typedef unsigned int BaseFlags
;
834 unsigned (*test_callback
)(BaseFlags inFlags
);
836 // expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
838 int test_verbatim_1();
840 // expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
842 int test_verbatim_2();
844 // FIXME: we give a bad diagnostic here because we throw away non-documentation
847 // expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
851 int test_verbatim_3();
854 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
855 int test1
; ///< \brief\author Aaa
857 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
858 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
859 int test2
, ///< \brief\author Aaa
860 test3
; ///< \brief\author Aaa
862 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
863 int test4
; ///< \brief
867 class TestRelates
{};
869 /// \relates TestRelates
871 void test_relates_1();
873 /// \related TestRelates
875 void test_relates_2();
877 /// \relatesalso TestRelates
879 void test_relates_3();
881 /// \relatedalso TestRelates
883 void test_relates_4();
886 // Check that we attach the comment to the declaration during parsing in the
887 // following cases. The test is based on the fact that we don't parse
888 // documentation comments that are not attached to anything.
890 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
891 /// \brief\author Aaa
894 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
895 /// \brief\author Aaa
896 int test_attach2(int);
898 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
899 /// \brief\author Aaa
900 struct test_attach3
{
901 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
902 /// \brief\author Aaa
905 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
906 int test_attach5
; ///< \brief\author Aaa
908 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
909 /// \brief\author Aaa
910 int test_attach6(int);
913 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
914 /// \brief\author Aaa
916 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
917 /// \brief\author Aaa
920 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
921 int test_attach9
; ///< \brief\author Aaa
923 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
924 /// \brief\author Aaa
925 int test_attach10(int);
928 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
929 /// \brief\author Aaa
931 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
932 /// \brief\author Aaa
935 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
936 test_attach11
///< \brief\author Aaa
939 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
940 /// \brief\author Aaa
941 struct test_noattach12
*test_attach13
;
943 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
944 /// \brief\author Aaa
945 typedef struct test_noattach14
*test_attach15
;
947 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}}
948 /// \brief\author Aaa
949 typedef struct test_attach16
{ int a
; } test_attach17
;
953 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
954 /// \brief\author Aaa
955 struct S
*test_attach18
;
957 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
958 /// \brief\author Aaa
959 typedef struct S
*test_attach19
;
961 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
962 /// \brief\author Aaa
963 struct test_attach20
;
965 // expected-warning@+1 + {{empty paragraph passed to '\brief' command}}
966 /// \brief\author Aaa
967 typedef struct test_attach21
{
968 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
969 /// \brief\author Aaa
973 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
974 /// \brief\author Aaa
975 namespace test_attach24
{
976 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
977 /// \brief\author Aaa
978 namespace test_attach25
{
982 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
983 /// \brief\author Aaa
986 void test_attach26(T aaa
);
988 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
989 /// \brief\author Aaa
991 template<typename T
, typename U
>
992 void test_attach27(T aaa
, U bbb
);
994 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
995 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
996 /// \brief\author Aaa
999 void test_attach27(int aaa
, int bbb
);
1001 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1002 /// \brief\author Aaa
1004 template<typename T
>
1005 class test_attach28
{
1009 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1010 /// \brief\author Aaa
1011 using test_attach29
= test_attach28
<int>;
1013 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1014 /// \brief\author Aaa
1016 template<typename T
, typename U
>
1017 class test_attach30
{ };
1019 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1020 /// \brief\author Aaa
1022 template<typename T
>
1023 class test_attach30
<T
, int> { };
1025 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1026 /// \brief\author Aaa
1028 class test_attach30
<int, int> { };
1030 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1031 /// \brief\author Aaa
1032 template<typename T
>
1033 using test_attach31
= test_attach30
<T
, int>;
1035 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1036 /// \brief\author Aaa
1038 template<typename T
, typename U
, typename V
>
1039 class test_attach32
{ };
1041 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1042 /// \brief\author Aaa
1044 template<typename T
, typename U
>
1045 class test_attach32
<T
, U
, int> { };
1047 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1048 /// \brief\author Aaa
1050 template<typename T
>
1051 class test_attach32
<T
, int, int> { };
1053 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1054 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1055 /// \brief\author Aaa
1058 class test_attach32
<int, int, int> { };
1060 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1061 /// \brief\author Aaa
1062 class test_attach33
{
1063 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1064 /// \brief\author Aaa
1066 template<typename T
, typename U
>
1067 void test_attach34(T aaa
, U bbb
);
1070 template<typename T
>
1071 class test_attach35
{
1072 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1073 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1074 /// \brief\author Aaa
1076 template<typename TT
, typename UU
>
1077 void test_attach36(TT aaa
, UU bbb
);
1080 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1081 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1082 /// \brief\author Aaa
1084 template<> template<>
1085 void test_attach35
<int>::test_attach36(int aaa
, int bbb
) {}
1087 template<typename T
>
1088 class test_attach37
{
1089 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1090 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
1091 /// \brief\author Aaa
1093 void test_attach38(int aaa
, int bbb
);
1095 void test_attach39(int aaa
, int bbb
);
1098 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
1099 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
1100 /// \brief\author Aaa
1103 void test_attach37
<int>::test_attach38(int aaa
, int bbb
) {}
1105 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1106 /// \brief\author Aaa
1108 template<typename T
>
1109 void test_attach37
<T
>::test_attach39(int aaa
, int bbb
) {}
1111 // We used to emit warning that parameter 'a' is not found because we parsed
1112 // the comment in context of the redeclaration which does not have parameter
1114 template <typename T
>
1115 struct test_attach38
{
1117 \param a First param
1118 \param b Second param
1120 template <typename B
>
1121 void test_attach39(T a
, B b
);
1125 template <typename B
>
1126 void test_attach38
<int>::test_attach39(int, B
);
1128 // The inline comments expect a string after the command.
1129 // expected-warning@+1 {{'\a' command has no word arguments, expected 1}}
1131 int test_inline_no_argument_a_bad(int);
1134 int test_inline_no_argument_a_good(int);
1136 // expected-warning@+1 {{'\anchor' command has no word arguments, expected 1}}
1138 int test_inline_no_argument_anchor_bad(int);
1141 int test_inline_no_argument_anchor_good(int);
1143 // expected-warning@+1 {{'@b' command has no word arguments, expected 1}}
1145 int test_inline_no_argument_b_bad(int);
1148 int test_inline_no_argument_b_good(int);
1150 // expected-warning@+1 {{'\c' command has no word arguments, expected 1}}
1152 int test_inline_no_argument_c_bad(int);
1155 int test_inline_no_argument_c_good(int);
1157 // expected-warning@+1 {{'\e' command has no word arguments, expected 1}}
1159 int test_inline_no_argument_e_bad(int);
1162 int test_inline_no_argument_e_good(int);
1164 // expected-warning@+1 {{'\em' command has no word arguments, expected 1}}
1166 int test_inline_no_argument_em_bad(int);
1169 int test_inline_no_argument_em_good(int);
1171 // expected-warning@+1 {{'\p' command has no word arguments, expected 1}}
1173 int test_inline_no_argument_p_bad(int);
1176 int test_inline_no_argument_p_good(int);
1178 // PR13411, reduced. We used to crash on this.
1182 void test_nocrash1(int);
1184 // We used to crash on this.
1185 // expected-warning@+2 {{empty paragraph passed to '\param' command}}
1186 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
1188 void test_nocrash2(int);
1190 // PR13593, example 1 and 2
1196 void test_nocrash3();
1199 template <typename
, typename
>
1200 void test_nocrash4() { }
1203 void test_nocrash3()
1207 // PR13593, example 3
1212 template <typename T
>
1213 inline T
test_nocrash5(T a1
)
1221 inline void test_nocrash6()
1226 // We used to crash on this.
1231 typedef const struct test_nocrash7
* test_nocrash8
;
1233 // We used to crash on this.
1235 // expected-warning@+1 {{unknown command tag name}}
1236 /// aaa \unknown aaa \unknown aaa
1239 // We used to crash on this. PR15068
1241 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1242 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1245 int test_nocrash10(int x
, int y
);
1247 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
1248 // expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
1251 int test_nocrash11();
1253 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
1254 // expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
1259 int test_nocrash12();
1261 // expected-warning@+2 {{empty paragraph passed to '@param' command}}
1262 // expected-warning@+1 {{empty paragraph passed to '@param' command}}
1264 int test_nocrash13(int x
, int y
);
1270 int test_nocrash14();
1272 // expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
1274 @union U This is new
1276 struct U
{ int iS
; };
1283 // expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
1299 //----------------------------------------------------------------------
1300 /// @class Predicate Predicate.h "lldb/Host/Predicate.h"
1301 /// @brief A C++ wrapper class for providing threaded access to a value
1304 /// A templatized class.
1305 /// specified values.
1306 //----------------------------------------------------------------------
1307 template <class T
, class T1
>
1312 //----------------------------------------------------------------------
1313 /// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
1314 /// @brief A C++ wrapper class for providing threaded access to a value
1317 /// A template specialization class.
1318 //----------------------------------------------------------------------
1319 template<> class Predicate
<int, char>
1323 //----------------------------------------------------------------------
1324 /// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
1325 /// @brief A C++ wrapper class for providing threaded access to a value
1328 /// A partial specialization template class.
1329 //----------------------------------------------------------------------
1330 template<class T
> class Predicate
<T
, int>
1334 /*! @function test_function
1336 template <class T
> T
test_function (T arg
);
1338 /*! @function test_function<int>
1340 template <> int test_function
<int> (int arg
);
1342 namespace AllowParamAndReturnsOnFunctionPointerVars
{
1345 * functionPointerVariable
1347 * @param i is integer.
1350 int (*functionPointerVariable
)(int i
);
1352 #if __cplusplus >= 201402L
1354 * functionPointerVariableTemplate
1356 * @param i is something.
1359 template<typename T
>
1360 int (*functionPointerVariableTemplate
)(T i
);
1365 * functionPointerField
1367 * @param i is integer.
1370 int (*functionPointerField
)(int i
);
1372 #if __cplusplus >= 201402L
1374 * functionPointerTemplateMember
1376 * @tparam T some type.
1377 * @param i is integer.
1380 template<typename T
>
1381 static int (*functionPointerTemplateMember
)(int i
);
1385 // expected-warning@+5 {{parameter 'p' not found in the function declaration}}
1386 // expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}
1388 * functionPointerVariable
1390 * \param p not here.
1393 void (*functionPointerVariableThatLeadsNowhere
)();
1395 #if __cplusplus >= 201402L
1396 // expected-warning@+8 {{template parameter 'X' not found in the template declaration}}
1397 // expected-note@+7 {{did you mean 'T'?}}
1398 // expected-warning@+7 {{parameter 'p' not found in the function declaration}}
1399 // expected-note@+6 {{did you mean 'x'?}}
1400 // expected-warning@+6 {{'\returns' command used in a comment that is attached to a function returning void}}
1402 * functionPointerVariable
1405 * \param p not here.
1408 template<typename T
>
1409 void (*functionPointerVariableTemplateThatLeadsNowhere
)(T x
);
1412 // Still warn about param/returns commands for variables that don't specify
1413 // the type directly:
1416 * FunctionPointerTypedef
1418 * \param i is integer.
1421 typedef int (*FunctionPointerTypedef
)(int i
);
1424 * FunctionPointerTypealias
1426 * \param i is integer.
1429 using FunctionPointerTypealias
= int (*)(int i
);
1431 // expected-warning@+5 {{'@param' command used in a comment that is not attached to a function declaration}}
1432 // expected-warning@+5 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
1434 * functionPointerVariable
1436 * @param i is integer.
1439 FunctionPointerTypedef functionPointerTypedefVariable
;
1441 struct HasMoreFields
{
1442 // expected-warning@+5 {{'\param' command used in a comment that is not attached to a function declaration}}
1443 // expected-warning@+5 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
1445 * functionPointerTypealiasField
1447 * \param i is integer.
1450 FunctionPointerTypealias functionPointerTypealiasField
;
1456 * Function pointer typedef with variadic params.
1462 * now should work too.
1464 typedef void (*VariadicFnType
)(int a
, ...);
1467 * Function pointer type alias with variadic params.
1473 * now should work too.
1475 using VariadicFnType2
= void (*)(int a
, ...);
1478 * Function pointer type variable.
1484 * now should work too.
1486 void (*variadicFnVar
)(int a
, ...);
1488 // expected-warning@+2 {{empty paragraph passed to '@note' command}}
1491 \f$\texttt{mu}_{00}=\texttt{m}_{00}\f$, \f$\texttt{nu}_{00}=1\f$
1492 \f$\texttt{nu}_{10}=\texttt{mu}_{10}=\texttt{mu}_{01}=\texttt{mu}_{10}=0\f$
1494 class EmptyNoteNoCrash
{
1497 namespace PR42844
{ // Assertion failures when using typedefed function pointers
1498 typedef void (*AA
)();
1500 A
*a
; ///< \return none
1501 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1504 B
*b
; ///< \return none
1505 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1509 C
&c
= CC
; ///< \return none
1510 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1512 using DD
= void(*)();
1514 D
*d
; ///< \return none
1515 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1518 E
*e
; ///< \return none
1519 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1523 F
&f
= FF
; ///< \return none
1524 // expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
1526 } // namespace PR42844