blob: 00c56015b6ca9b25a4a1cd8acb0835beb2e282bc [file] [log] [blame]
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
Dmitri Gribenkof26054f2012-07-11 21:38:39 +00002
Dmitri Gribenko740c0fb2012-08-07 17:54:38 +00003// 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
Dmitri Gribenkof26054f2012-07-11 21:38:39 +00007// 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}}
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000016// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000017/// <a href= blah
18int test_html3(int);
19
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000020// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000021/// <a =>
22int test_html4(int);
23
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000024// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000025/// <a "aaa">
26int test_html5(int);
27
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000028// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000029/// <a a="b" =>
30int test_html6(int);
31
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000032// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000033/// <a a="b" "aaa">
34int test_html7(int);
35
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000036// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000037/// <a a="b" =
38int test_html8(int);
39
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000040// expected-warning@+2 {{HTML start tag prematurely ended, expected attribute name or '>'}} expected-note@+1 {{HTML tag started here}}
Dmitri Gribenko107618a2012-08-22 22:56:08 +000041/** Aaa bbb<img ddd eee
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000042 * fff ggg.
43 */
44int test_html9(int);
45
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000046// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenko107618a2012-08-22 22:56:08 +000047/** Aaa bbb<img ddd eee 42%
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000048 * fff ggg.
49 */
50int test_html10(int);
51
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000052// expected-warning@+1 {{HTML end tag 'br' is forbidden}}
Dmitri Gribenko9460fbf2012-07-12 23:37:09 +000053/// <br></br>
54int test_html11(int);
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000055
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
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000070// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000071/// <b><i>Meow</a>
72int test_html_nesting5(int);
73
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000074// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
75// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000076/// <b><i>Meow</b></b>
77int test_html_nesting6(int);
78
Dmitri Gribenkoe00ffc72012-07-13 00:44:24 +000079// expected-warning@+2 {{HTML start tag 'i' closed by 'b'}}
80// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000081/// <b><i>Meow</b></i>
82int test_html_nesting7(int);
83
84
85// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +000086/// \brief\returns Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000087int test_block_command1(int);
88
89// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +000090/// \brief \returns Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000091int test_block_command2(int);
92
93// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
94/// \brief
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +000095/// \returns Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +000096int test_block_command3(int);
97
98// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
99/// \brief
100///
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000101/// \returns Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000102int 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///
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000108/// \returns Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000109int test_block_command5(int);
110
Dmitri Gribenko7b2ca3e2012-07-19 00:01:56 +0000111/// \brief \c Aaa
112int test_block_command6(int);
113
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000114// 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
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000139/// \return Aaa
140///
141/// Bbb
142///
143/// \return Ccc
Dmitri Gribenkod6662932013-06-22 23:03:37 +0000144int test_multiple_returns1(int);
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000145
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000146/// \returns Aaa
147///
148/// Bbb
149///
150/// \returns Ccc
Dmitri Gribenkod6662932013-06-22 23:03:37 +0000151int test_multiple_returns2(int);
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000152
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000153/// \result Aaa
154///
155/// Bbb
156///
157/// \result Ccc
Dmitri Gribenkod6662932013-06-22 23:03:37 +0000158int test_multiple_returns3(int);
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000159
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000160/// \returns Aaa
161///
162/// Bbb
163///
164/// \return Ccc
Dmitri Gribenkod6662932013-06-22 23:03:37 +0000165int test_multiple_returns4(int);
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000166
167
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000168// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
169/// \param a Blah blah.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000170int test_param1_backslash;
171
172// rdar://13066276
173// Check that the diagnostic uses the same command marker as the comment.
174// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
175/// @param a Blah blah.
176int test_param1_at;
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000177
178// expected-warning@+1 {{empty paragraph passed to '\param' command}}
179/// \param
180/// \param a Blah blah.
181int test_param2(int a);
182
183// expected-warning@+1 {{empty paragraph passed to '\param' command}}
184/// \param a
185int test_param3(int a);
186
187/// \param a Blah blah.
188int test_param4(int a);
189
190/// \param [in] a Blah blah.
191int test_param5(int a);
192
193/// \param [out] a Blah blah.
194int test_param6(int a);
195
196/// \param [in,out] a Blah blah.
197int test_param7(int a);
198
199// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
200/// \param [ in ] a Blah blah.
201int test_param8(int a);
202
203// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
204/// \param [in, out] a Blah blah.
205int test_param9(int a);
206
207// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
208/// \param [ junk] a Blah blah.
209int test_param10(int a);
210
Dmitri Gribenko3c541282012-07-24 21:56:59 +0000211// expected-warning@+1 {{parameter 'a' not found in the function declaration}}
Dmitri Gribenko5b8a1d42012-07-24 21:46:24 +0000212/// \param a Blah blah.
213int test_param11();
214
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000215// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
216/// \param A Blah blah.
Dmitri Gribenko5b8a1d42012-07-24 21:46:24 +0000217int test_param12(int a);
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000218
219// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
220/// \param aab Blah blah.
Dmitri Gribenko5b8a1d42012-07-24 21:46:24 +0000221int test_param13(int aaa, int bbb);
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000222
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000223// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
224/// \param aaa Blah blah.
225/// \param aab Blah blah.
226int test_param14(int aaa, int bbb);
227
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000228// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
229/// \param aab Blah blah.
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000230int test_param15(int bbb, int ccc);
231
232// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
233/// \param aab Ccc.
234/// \param aaa Aaa.
235/// \param bbb Bbb.
236int test_param16(int aaa, int bbb);
237
238// expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
239/// \param aaa Aaa.
240/// \param aab Ccc.
241/// \param bbb Bbb.
242int test_param17(int aaa, int bbb);
243
244// expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
245/// \param aaa Aaa.
246/// \param bbb Bbb.
247/// \param aab Ccc.
248int test_param18(int aaa, int bbb);
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000249
250class C {
251 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
252 /// \param aaa Blah blah.
253 C(int bbb, int ccc);
254
255 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
256 /// \param aaa Blah blah.
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000257 int test_param19(int bbb, int ccc);
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000258};
259
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000260// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
261/// \param aab Blah blah.
262template<typename T>
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000263void test_param20(int bbb, int ccc);
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000264
Dmitri Gribenko8f0f1b02012-07-24 21:44:16 +0000265// expected-warning@+3 {{parameter 'a' is already documented}}
266// expected-note@+1 {{previous documentation}}
267/// \param a Aaa.
268/// \param a Aaa.
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000269int test_param21(int a);
Dmitri Gribenko8f0f1b02012-07-24 21:44:16 +0000270
271// expected-warning@+4 {{parameter 'x2' is already documented}}
272// expected-note@+2 {{previous documentation}}
273/// \param x1 Aaa.
274/// \param x2 Bbb.
275/// \param x2 Ccc.
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000276int test_param22(int x1, int x2, int x3);
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000277
Dmitri Gribenkofa68a572013-12-17 22:06:11 +0000278//===---
279// Test that we treat typedefs to some non-function types as functions for the
280// purposes of documentation comment parsing.
281//===---
282
283namespace foo {
284 inline namespace bar {
285 template<typename>
286 struct function_wrapper {};
287
288 template<unsigned>
289 struct not_a_function_wrapper {};
290 }
291};
292
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000293// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000294/// \param aaa Meow.
295/// \param bbb Bbb.
296/// \returns aaa.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000297typedef int test_function_like_typedef1(int aaa, int ccc);
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000298
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000299// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000300/// \param aaa Meow.
301/// \param bbb Bbb.
302/// \returns aaa.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000303typedef int (*test_function_like_typedef2)(int aaa, int ccc);
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000304
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000305// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000306/// \param aaa Meow.
307/// \param bbb Bbb.
308/// \returns aaa.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000309typedef int (* const test_function_like_typedef3)(int aaa, int ccc);
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000310
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000311// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko907f6b82012-08-24 00:05:30 +0000312/// \param aaa Meow.
313/// \param bbb Bbb.
314/// \returns aaa.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000315typedef int (C::*test_function_like_typedef4)(int aaa, int ccc);
Dmitri Gribenko219bd152012-08-24 17:45:39 +0000316
Dmitri Gribenkofa68a572013-12-17 22:06:11 +0000317// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
318/// \param aaa Meow.
319/// \param bbb Bbb.
320/// \returns aaa.
321typedef foo::function_wrapper<int (int aaa, int ccc)> test_function_like_typedef5;
322
323// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
324/// \param aaa Meow.
325/// \param bbb Bbb.
326/// \returns aaa.
327typedef foo::function_wrapper<int (int aaa, int ccc)> *test_function_like_typedef6;
328
329
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000330typedef int (*test_not_function_like_typedef1)(int aaa);
Dmitri Gribenko49fdf8d2012-09-15 21:13:36 +0000331
332// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
333/// \param aaa Meow.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000334typedef test_not_function_like_typedef1 test_not_function_like_typedef2;
Dmitri Gribenko49fdf8d2012-09-15 21:13:36 +0000335
Dmitri Gribenkofd5ef422013-03-04 19:39:33 +0000336// rdar://13066276
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000337// Check that the diagnostic uses the same command marker as the comment.
Dmitri Gribenkofd5ef422013-03-04 19:39:33 +0000338// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
339/// @param aaa Meow.
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000340typedef unsigned int test_not_function_like_typedef3;
Dmitri Gribenkofd5ef422013-03-04 19:39:33 +0000341
Dmitri Gribenkofa68a572013-12-17 22:06:11 +0000342// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
343/// \param aaa Meow.
344typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000345
Dmitri Gribenko02489eb2013-06-24 04:41:32 +0000346/// \param aaa Aaa
347/// \param ... Vararg
348int test_vararg_param1(int aaa, ...);
349
350/// \param ... Vararg
351int test_vararg_param2(...);
352
353// expected-warning@+1 {{parameter '...' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
354/// \param ... Vararg
355int test_vararg_param3(int aaa);
356
357// expected-warning@+1 {{parameter '...' not found in the function declaration}}
358/// \param ... Vararg
359int test_vararg_param4();
360
361
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000362// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
363/// \tparam T Aaa
364int test_tparam1;
365
366// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
367/// \tparam T Aaa
368void test_tparam2(int aaa);
369
370// expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
371/// \tparam
372/// \param aaa Blah blah
373template<typename T>
374void test_tparam3(T aaa);
375
376// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
377/// \tparam T Aaa
378template<typename TT>
379void test_tparam4(TT aaa);
380
381// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
382/// \tparam T Aaa
383template<typename TT>
384class test_tparam5 {
385 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
386 /// \tparam T Aaa
387 template<typename TTT>
388 void test_tparam6(TTT aaa);
389};
390
391/// \tparam T1 Aaa
392/// \tparam T2 Bbb
393template<typename T1, typename T2>
394void test_tparam7(T1 aaa, T2 bbb);
395
396// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
397/// \tparam SomTy Aaa
398/// \tparam OtherTy Bbb
399template<typename SomeTy, typename OtherTy>
400void test_tparam8(SomeTy aaa, OtherTy bbb);
401
402// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
403/// \tparam T1 Aaa
404/// \tparam T1 Bbb
405template<typename T1, typename T2>
406void test_tparam9(T1 aaa, T2 bbb);
407
408/// \tparam T Aaa
409/// \tparam TT Bbb
410template<template<typename T> class TT>
411void test_tparam10(TT<int> aaa);
412
413/// \tparam T Aaa
414/// \tparam TT Bbb
415/// \tparam TTT Ccc
416template<template<template<typename T> class TT, class C> class TTT>
417void test_tparam11();
418
419/// \tparam I Aaa
420template<int I>
421void test_tparam12();
422
Dmitri Gribenkobaeb60e2012-08-02 21:36:57 +0000423template<typename T, typename U>
424class test_tparam13 { };
425
426/// \tparam T Aaa
427template<typename T>
428using test_tparam14 = test_tparam13<T, int>;
429
430// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
431/// \tparam U Aaa
432template<typename T>
433using test_tparam15 = test_tparam13<T, int>;
434
Dmitri Gribenko01b06512013-01-27 21:18:39 +0000435// ----
436
437/// \tparam T Aaa
438template<typename T>
439class test_tparam16 { };
440
441typedef test_tparam16<int> test_tparam17;
442typedef test_tparam16<double> test_tparam18;
443
444// ----
445
446template<typename T>
447class test_tparam19;
448
449typedef test_tparam19<int> test_tparam20;
450typedef test_tparam19<double> test_tparam21;
451
452/// \tparam T Aaa
453template<typename T>
454class test_tparam19 { };
455
456// ----
457
Dmitri Gribenko05e22f22013-03-04 20:23:16 +0000458// expected-warning@+1 {{'@tparam' command used in a comment that is not attached to a template declaration}}
459/// @tparam T Aaa
460int test_tparam22;
461
462// ----
463
Dmitri Gribenkob37d5e82012-09-13 20:36:01 +0000464
465/// Aaa
466/// \deprecated Bbb
Dmitri Gribenko1da88862012-09-22 21:47:50 +0000467void test_deprecated_1(int a) __attribute__((deprecated));
Dmitri Gribenkob37d5e82012-09-13 20:36:01 +0000468
469// We don't want \deprecated to warn about empty paragraph. It is fine to use
470// \deprecated by itself without explanations.
471
472/// Aaa
473/// \deprecated
Dmitri Gribenko1da88862012-09-22 21:47:50 +0000474void test_deprecated_2(int a) __attribute__((deprecated));
475
476/// Aaa
477/// \deprecated
478void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
479
480/// Aaa
481/// \deprecated
482void test_deprecated_4(int a) __attribute__((unavailable));
483
484// 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}}
485/// Aaa
486/// \deprecated
487void test_deprecated_5(int a);
488
489// 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}}
490/// Aaa
491/// \deprecated
492void test_deprecated_6(int a) {
493}
494
495// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
496/// Aaa
497/// \deprecated
498template<typename T>
499void test_deprecated_7(T aaa);
Dmitri Gribenkob37d5e82012-09-13 20:36:01 +0000500
501
Dmitri Gribenkofd5ef422013-03-04 19:39:33 +0000502// rdar://12397511
503// expected-note@+2 {{previous command '\headerfile' here}}
504// expected-warning@+2 {{duplicated command '\headerfile'}}
505/// \headerfile ""
506/// \headerfile foo.h
507int test__headerfile_1(int a);
508
509
Dmitri Gribenko578865b2012-09-14 15:37:29 +0000510/// \invariant aaa
511void test_invariant_1(int a);
512
513// expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
514/// \invariant
515void test_invariant_2(int a);
516
517
Dmitri Gribenko64305832012-08-03 21:15:32 +0000518// no-warning
519/// \returns Aaa
520int test_returns_right_decl_1(int);
521
522class test_returns_right_decl_2 {
523 // no-warning
524 /// \returns Aaa
525 int test_returns_right_decl_3(int);
526};
527
528// no-warning
529/// \returns Aaa
530template<typename T>
531int test_returns_right_decl_4(T aaa);
532
533// no-warning
534/// \returns Aaa
535template<>
536int test_returns_right_decl_4(int aaa);
537
538/// \returns Aaa
539template<typename T>
540T test_returns_right_decl_5(T aaa);
541
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000542// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000543/// \returns Aaa
Dmitri Gribenkof869ad12013-12-17 19:45:12 +0000544int test_returns_wrong_decl_1_backslash;
545
546// rdar://13066276
547// Check that the diagnostic uses the same command marker as the comment.
548// expected-warning@+1 {{'@returns' command used in a comment that is not attached to a function or method declaration}}
549/// @returns Aaa
550int test_returns_wrong_decl_1_at;
Dmitri Gribenko64305832012-08-03 21:15:32 +0000551
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000552// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000553/// \return Aaa
554int test_returns_wrong_decl_2;
555
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000556// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000557/// \result Aaa
558int test_returns_wrong_decl_3;
559
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000560// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000561/// \returns Aaa
562void test_returns_wrong_decl_4(int);
563
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000564// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000565/// \returns Aaa
566template<typename T>
567void test_returns_wrong_decl_5(T aaa);
568
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000569// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000570/// \returns Aaa
571template<>
572void test_returns_wrong_decl_5(int aaa);
573
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000574// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000575/// \returns Aaa
576struct test_returns_wrong_decl_6 { };
577
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000578// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000579/// \returns Aaa
580class test_returns_wrong_decl_7 {
581 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
582 /// \returns Aaa
583 test_returns_wrong_decl_7();
584
585 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
586 /// \returns Aaa
587 ~test_returns_wrong_decl_7();
588};
589
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000590// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000591/// \returns Aaa
592enum test_returns_wrong_decl_8 {
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000593 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000594 /// \returns Aaa
595 test_returns_wrong_decl_9
596};
597
Dmitri Gribenko558babc2012-08-06 16:29:26 +0000598// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko64305832012-08-03 21:15:32 +0000599/// \returns Aaa
600namespace test_returns_wrong_decl_10 { };
601
Fariborz Jahanianf4ba35d2013-03-05 19:40:47 +0000602// rdar://13094352
Fariborz Jahanian56fe4062013-03-05 22:46:07 +0000603// expected-warning@+1 {{'@function' command should be used in a comment attached to a function declaration}}
Fariborz Jahanianf4ba35d2013-03-05 19:40:47 +0000604/*! @function test_function
605*/
606typedef unsigned int Base64Flags;
607unsigned test_function(Base64Flags inFlags);
608
Fariborz Jahanian56fe4062013-03-05 22:46:07 +0000609// expected-warning@+1 {{'@callback' command should be used in a comment attached to a pointer to function declaration}}
Fariborz Jahanianf4ba35d2013-03-05 19:40:47 +0000610/*! @callback test_callback
611*/
612typedef unsigned int BaseFlags;
613unsigned (*test_callback)(BaseFlags inFlags);
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000614
Dmitri Gribenko76b91c32012-11-18 00:30:31 +0000615// expected-warning@+1 {{'\endverbatim' command does not terminate a verbatim text block}}
616/// \endverbatim
617int test_verbatim_1();
618
619// expected-warning@+1 {{'\endcode' command does not terminate a verbatim text block}}
620/// \endcode
621int test_verbatim_2();
622
623// FIXME: we give a bad diagnostic here because we throw away non-documentation
624// comments early.
625//
NAKAMURA Takumi34245502012-11-18 02:34:33 +0000626// expected-warning@+3 {{'\endcode' command does not terminate a verbatim text block}}
Dmitri Gribenko76b91c32012-11-18 00:30:31 +0000627/// \code
628// foo
629/// \endcode
630int test_verbatim_3();
631
632
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000633// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000634int test1; ///< \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000635
636// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
637// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000638int test2, ///< \brief\author Aaa
639 test3; ///< \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000640
641// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
642int test4; ///< \brief
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000643 ///< \author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000644
645
Dmitri Gribenko761f8012013-06-23 23:33:14 +0000646class TestRelates {};
647
648/// \relates TestRelates
649/// \brief Aaa
650void test_relates_1();
651
652/// \related TestRelates
653/// \brief Aaa
654void test_relates_2();
655
656/// \relatesalso TestRelates
657/// \brief Aaa
658void test_relates_3();
659
660/// \relatedalso TestRelates
661/// \brief Aaa
662void test_relates_4();
663
664
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000665// Check that we attach the comment to the declaration during parsing in the
666// following cases. The test is based on the fact that we don't parse
667// documentation comments that are not attached to anything.
668
669// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000670/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000671int test_attach1;
672
673// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000674/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000675int test_attach2(int);
676
677// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000678/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000679struct test_attach3 {
680 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000681 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000682 int test_attach4;
683
684 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000685 int test_attach5; ///< \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000686
687 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000688 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000689 int test_attach6(int);
690};
691
692// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000693/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000694class test_attach7 {
695 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000696 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000697 int test_attach8;
698
699 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000700 int test_attach9; ///< \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000701
702 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000703 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000704 int test_attach10(int);
705};
706
707// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000708/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000709enum test_attach9 {
710 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000711 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000712 test_attach10,
713
714 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000715 test_attach11 ///< \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000716};
717
718// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000719/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000720struct test_noattach12 *test_attach13;
721
722// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000723/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000724typedef struct test_noattach14 *test_attach15;
725
726// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000727/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000728typedef struct test_attach16 { int a; } test_attach17;
729
730struct S { int a; };
731
732// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000733/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000734struct S *test_attach18;
735
736// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000737/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000738typedef struct S *test_attach19;
739
740// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000741/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000742struct test_attach20;
743
744// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000745/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000746typedef struct test_attach21 {
747 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000748 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000749 int test_attach22;
750} test_attach23;
751
752// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000753/// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000754namespace test_attach24 {
755 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000756 /// \brief\author Aaa
Dmitri Gribenkof26054f2012-07-11 21:38:39 +0000757 namespace test_attach25 {
758 }
759}
760
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000761// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000762/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000763/// \tparam T Aaa
764template<typename T>
765void test_attach26(T aaa);
766
767// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000768/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000769/// \tparam T Aaa
770template<typename T, typename U>
771void test_attach27(T aaa, U bbb);
772
773// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
774// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000775/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000776/// \tparam T Aaa
777template<>
778void test_attach27(int aaa, int bbb);
779
780// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000781/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000782/// \tparam T Aaa
783template<typename T>
784class test_attach28 {
785 T aaa;
786};
787
788// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000789/// \brief\author Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000790using test_attach29 = test_attach28<int>;
791
792// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000793/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000794/// \tparam T Aaa
795template<typename T, typename U>
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000796class test_attach30 { };
797
798// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000799/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000800/// \tparam T Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000801template<typename T>
802class test_attach30<T, int> { };
803
804// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000805/// \brief\author Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000806template<>
807class test_attach30<int, int> { };
808
809// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000810/// \brief\author Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000811template<typename T>
812using test_attach31 = test_attach30<T, int>;
813
814// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000815/// \brief\author Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000816/// \tparam T Aaa
817template<typename T, typename U, typename V>
818class test_attach32 { };
819
820// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000821/// \brief\author Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000822/// \tparam T Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000823template<typename T, typename U>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000824class test_attach32<T, U, int> { };
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000825
826// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000827/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000828/// \tparam T Aaa
829template<typename T>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000830class test_attach32<T, int, int> { };
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000831
832// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
833// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000834/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000835/// \tparam T Aaa
836template<>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000837class test_attach32<int, int, int> { };
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000838
839// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000840/// \brief\author Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000841class test_attach33 {
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000842 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000843 /// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000844 /// \tparam T Aaa
845 template<typename T, typename U>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000846 void test_attach34(T aaa, U bbb);
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000847};
848
849template<typename T>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000850class test_attach35 {
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000851 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
852 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000853 /// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000854 /// \tparam T Aaa
855 template<typename TT, typename UU>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000856 void test_attach36(TT aaa, UU bbb);
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000857};
858
859// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
860// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000861/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000862/// \tparam T Aaa
863template<> template<>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000864void test_attach35<int>::test_attach36(int aaa, int bbb) {}
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000865
866template<typename T>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000867class test_attach37 {
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000868 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
869 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000870 /// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000871 /// \tparam T Aaa
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000872 void test_attach38(int aaa, int bbb);
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000873
Dmitri Gribenkob2610882012-08-14 17:17:18 +0000874 void test_attach39(int aaa, int bbb);
875};
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000876
877// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
878// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko5ec0c752012-08-06 17:08:27 +0000879/// \brief\author Aaa
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000880/// \tparam T Aaa
881template<>
Dmitri Gribenko7f4b3772012-08-02 20:49:51 +0000882void test_attach37<int>::test_attach38(int aaa, int bbb) {}
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000883
Dmitri Gribenkob2610882012-08-14 17:17:18 +0000884// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
885/// \brief\author Aaa
886/// \tparam T Aaa
887template<typename T>
888void test_attach37<T>::test_attach39(int aaa, int bbb) {}
889
Dmitri Gribenko4ae66a32012-08-16 18:19:43 +0000890// We used to emit warning that parameter 'a' is not found because we parsed
891// the comment in context of the redeclaration which does not have parameter
892// names.
893template <typename T>
894struct test_attach38 {
895 /*!
896 \param a First param
897 \param b Second param
898 */
899 template <typename B>
900 void test_attach39(T a, B b);
901};
902
903template <>
904template <typename B>
905void test_attach38<int>::test_attach39(int, B);
Dmitri Gribenkob2610882012-08-14 17:17:18 +0000906
Dmitri Gribenko34df2202012-07-31 22:37:06 +0000907
Dmitri Gribenko66a00c72012-07-20 20:18:53 +0000908// PR13411, reduced. We used to crash on this.
909/**
910 * @code Aaa.
911 */
912void test_nocrash1(int);
913
Dmitri Gribenko1ba47ca2012-07-30 18:05:28 +0000914// We used to crash on this.
915// expected-warning@+2 {{empty paragraph passed to '\param' command}}
916// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
917/// \param\brief
918void test_nocrash2(int);
919
Dmitri Gribenkob2610882012-08-14 17:17:18 +0000920// PR13593, example 1 and 2
Douglas Gregor35ceb272012-08-13 16:37:30 +0000921
922/**
923* Bla.
924*/
925template <typename>
926void test_nocrash3();
927
928/// Foo
929template <typename, typename>
930void test_nocrash4() { }
931
932template <typename>
933void test_nocrash3()
934{
935}
Dmitri Gribenkob2610882012-08-14 17:17:18 +0000936
937// PR13593, example 3
938
939/**
940 * aaa
941 */
942template <typename T>
943inline T test_nocrash5(T a1)
944{
945 return a1;
946}
947
948///
949//,
950
951inline void test_nocrash6()
952{
953 test_nocrash5(1);
954}
955
956// We used to crash on this.
957
958/*!
959 Blah.
960*/
961typedef const struct test_nocrash7 * test_nocrash8;
962
Dmitri Gribenko9304d862012-09-11 19:22:03 +0000963// We used to crash on this.
964
Fariborz Jahanian5b637072013-05-03 23:15:20 +0000965// expected-warning@+1 {{unknown command tag name}}
Dmitri Gribenko9304d862012-09-11 19:22:03 +0000966/// aaa \unknown aaa \unknown aaa
967int test_nocrash9;
968
Dmitri Gribenko71469302013-01-26 00:36:14 +0000969// We used to crash on this. PR15068
970
Fariborz Jahaniand4996362013-03-01 22:51:30 +0000971// expected-warning@+2 {{empty paragraph passed to '@param' command}}
972// expected-warning@+2 {{empty paragraph passed to '@param' command}}
Dmitri Gribenko71469302013-01-26 00:36:14 +0000973///@param x
974///@param y
975int test_nocrash10(int x, int y);
976
Fariborz Jahaniand4996362013-03-01 22:51:30 +0000977// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'x' not found in the function declaration}}
978// expected-warning@+2 {{empty paragraph passed to '@param' command}} expected-warning@+2 {{parameter 'y' not found in the function declaration}}
Dmitri Gribenko71469302013-01-26 00:36:14 +0000979///@param x
980///@param y
981int test_nocrash11();
982
Fariborz Jahaniand4996362013-03-01 22:51:30 +0000983// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'x' not found in the function declaration}}
984// expected-warning@+3 {{empty paragraph passed to '@param' command}} expected-warning@+3 {{parameter 'y' not found in the function declaration}}
Dmitri Gribenko71469302013-01-26 00:36:14 +0000985/**
986@param x
987@param y
988**/
989int test_nocrash12();
990
Fariborz Jahaniand4996362013-03-01 22:51:30 +0000991// expected-warning@+2 {{empty paragraph passed to '@param' command}}
992// expected-warning@+1 {{empty paragraph passed to '@param' command}}
Dmitri Gribenko71469302013-01-26 00:36:14 +0000993///@param x@param y
994int test_nocrash13(int x, int y);
Fariborz Jahaniana649eee2013-03-07 23:33:11 +0000995
996// rdar://12379114
997// expected-warning@+2 {{'@union' command should not be used in a comment attached to a non-union declaration}}
998/*!
999 @union U This is new
1000*/
1001struct U { int iS; };
1002
1003/*!
1004 @union U1
1005*/
1006union U1 {int i; };
1007
1008// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
1009/*!
1010 @struct S2
1011*/
1012union S2 {};
1013
1014/*!
1015 @class C1
1016*/
1017class C1;
1018
1019/*!
1020 @struct S3;
1021*/
1022class S3;
Fariborz Jahanianc0607ed2013-06-19 18:08:03 +00001023
1024// rdar://14124702
1025//----------------------------------------------------------------------
1026/// @class Predicate Predicate.h "lldb/Host/Predicate.h"
1027/// @brief A C++ wrapper class for providing threaded access to a value
1028/// of type T.
1029///
1030/// A templatized class.
1031/// specified values.
1032//----------------------------------------------------------------------
1033template <class T, class T1>
1034class Predicate
1035{
1036};
1037
1038//----------------------------------------------------------------------
1039/// @class Predicate<int, char> Predicate.h "lldb/Host/Predicate.h"
1040/// @brief A C++ wrapper class for providing threaded access to a value
1041/// of type T.
1042///
1043/// A template specilization class.
1044//----------------------------------------------------------------------
1045template<> class Predicate<int, char>
1046{
1047};
1048
1049//----------------------------------------------------------------------
1050/// @class Predicate<T, int> Predicate.h "lldb/Host/Predicate.h"
1051/// @brief A C++ wrapper class for providing threaded access to a value
1052/// of type T.
1053///
1054/// A partial specialization template class.
1055//----------------------------------------------------------------------
1056template<class T> class Predicate<T, int>
1057{
1058};
1059
1060/*! @function test_function
1061*/
1062template <class T> T test_function (T arg);
1063
1064/*! @function test_function<int>
1065*/
1066template <> int test_function<int> (int arg);