blob: b5d3300efd0f3b3542146ab67abd02e4aa7c13f9 [file] [log] [blame]
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +00001// RUN: %clang_cc1 -std=c++11 -fsyntax-only -Wdocumentation -Wdocumentation-pedantic -verify %s
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +00002
Dmitri Gribenkof303d4c2012-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 Gribenkoa5ef44f2012-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 Gribenko3f38bf22012-07-13 00:44:24 +000016// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000017/// <a href= blah
18int test_html3(int);
19
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000020// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000021/// <a =>
22int test_html4(int);
23
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000024// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000025/// <a "aaa">
26int test_html5(int);
27
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000028// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000029/// <a a="b" =>
30int test_html6(int);
31
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000032// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000033/// <a a="b" "aaa">
34int test_html7(int);
35
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000036// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000037/// <a a="b" =
38int test_html8(int);
39
Dmitri Gribenko3f38bf22012-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 Gribenko834a5bd2012-08-22 22:56:08 +000041/** Aaa bbb<img ddd eee
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000042 * fff ggg.
43 */
44int test_html9(int);
45
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000046// expected-warning@+1 {{HTML start tag prematurely ended, expected attribute name or '>'}}
Dmitri Gribenko834a5bd2012-08-22 22:56:08 +000047/** Aaa bbb<img ddd eee 42%
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000048 * fff ggg.
49 */
50int test_html10(int);
51
Dmitri Gribenko3f38bf22012-07-13 00:44:24 +000052// expected-warning@+1 {{HTML end tag 'br' is forbidden}}
Dmitri Gribenko3d986982012-07-12 23:37:09 +000053/// <br></br>
54int test_html11(int);
Dmitri Gribenkoa5ef44f2012-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 Gribenko3f38bf22012-07-13 00:44:24 +000070// expected-warning@+1 {{HTML end tag does not match any start tag}}
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000071/// <b><i>Meow</a>
72int test_html_nesting5(int);
73
Dmitri Gribenko3f38bf22012-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 Gribenkoa5ef44f2012-07-11 21:38:39 +000076/// <b><i>Meow</b></b>
77int test_html_nesting6(int);
78
Dmitri Gribenko3f38bf22012-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 Gribenkoa5ef44f2012-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 Gribenko9443c572012-08-06 17:08:27 +000086/// \brief\returns Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000087int test_block_command1(int);
88
89// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +000090/// \brief \returns Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +000091int test_block_command2(int);
92
93// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
94/// \brief
Dmitri Gribenko9443c572012-08-06 17:08:27 +000095/// \returns Aaa
Dmitri Gribenkoa5ef44f2012-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 Gribenko9443c572012-08-06 17:08:27 +0000101/// \returns Aaa
Dmitri Gribenkoa5ef44f2012-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 Gribenko9443c572012-08-06 17:08:27 +0000108/// \returns Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000109int test_block_command5(int);
110
Dmitri Gribenko858e69f2012-07-19 00:01:56 +0000111/// \brief \c Aaa
112int test_block_command6(int);
113
Dmitri Gribenko9443c572012-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
139// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\return' here}}
140/// \return Aaa
141///
142/// Bbb
143///
144/// \return Ccc
145int test_duplicate_returns1(int);
146
147// expected-warning@+5 {{duplicated command '\returns'}} expected-note@+1 {{previous command '\returns' here}}
148/// \returns Aaa
149///
150/// Bbb
151///
152/// \returns Ccc
153int test_duplicate_returns2(int);
154
155// expected-warning@+5 {{duplicated command '\result'}} expected-note@+1 {{previous command '\result' here}}
156/// \result Aaa
157///
158/// Bbb
159///
160/// \result Ccc
161int test_duplicate_returns3(int);
162
163// expected-warning@+5 {{duplicated command '\return'}} expected-note@+1 {{previous command '\returns' (an alias of '\return') here}}
164/// \returns Aaa
165///
166/// Bbb
167///
168/// \return Ccc
169int test_duplicate_returns4(int);
170
171
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000172// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
173/// \param a Blah blah.
174int test_param1;
175
176// expected-warning@+1 {{empty paragraph passed to '\param' command}}
177/// \param
178/// \param a Blah blah.
179int test_param2(int a);
180
181// expected-warning@+1 {{empty paragraph passed to '\param' command}}
182/// \param a
183int test_param3(int a);
184
185/// \param a Blah blah.
186int test_param4(int a);
187
188/// \param [in] a Blah blah.
189int test_param5(int a);
190
191/// \param [out] a Blah blah.
192int test_param6(int a);
193
194/// \param [in,out] a Blah blah.
195int test_param7(int a);
196
197// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
198/// \param [ in ] a Blah blah.
199int test_param8(int a);
200
201// expected-warning@+1 {{whitespace is not allowed in parameter passing direction}}
202/// \param [in, out] a Blah blah.
203int test_param9(int a);
204
205// expected-warning@+1 {{unrecognized parameter passing direction, valid directions are '[in]', '[out]' and '[in,out]'}}
206/// \param [ junk] a Blah blah.
207int test_param10(int a);
208
Dmitri Gribenko2e721042012-07-24 21:56:59 +0000209// expected-warning@+1 {{parameter 'a' not found in the function declaration}}
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000210/// \param a Blah blah.
211int test_param11();
212
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000213// expected-warning@+1 {{parameter 'A' not found in the function declaration}} expected-note@+1 {{did you mean 'a'?}}
214/// \param A Blah blah.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000215int test_param12(int a);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000216
217// expected-warning@+1 {{parameter 'aab' not found in the function declaration}} expected-note@+1 {{did you mean 'aaa'?}}
218/// \param aab Blah blah.
Dmitri Gribenko56bf6fd2012-07-24 21:46:24 +0000219int test_param13(int aaa, int bbb);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000220
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000221// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'bbb'?}}
222/// \param aaa Blah blah.
223/// \param aab Blah blah.
224int test_param14(int aaa, int bbb);
225
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000226// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
227/// \param aab Blah blah.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000228int test_param15(int bbb, int ccc);
229
230// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
231/// \param aab Ccc.
232/// \param aaa Aaa.
233/// \param bbb Bbb.
234int test_param16(int aaa, int bbb);
235
236// expected-warning@+2 {{parameter 'aab' not found in the function declaration}}
237/// \param aaa Aaa.
238/// \param aab Ccc.
239/// \param bbb Bbb.
240int test_param17(int aaa, int bbb);
241
242// expected-warning@+3 {{parameter 'aab' not found in the function declaration}}
243/// \param aaa Aaa.
244/// \param bbb Bbb.
245/// \param aab Ccc.
246int test_param18(int aaa, int bbb);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000247
248class C {
249 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
250 /// \param aaa Blah blah.
251 C(int bbb, int ccc);
252
253 // expected-warning@+1 {{parameter 'aaa' not found in the function declaration}}
254 /// \param aaa Blah blah.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000255 int test_param19(int bbb, int ccc);
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000256};
257
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000258// expected-warning@+1 {{parameter 'aab' not found in the function declaration}}
259/// \param aab Blah blah.
260template<typename T>
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000261void test_param20(int bbb, int ccc);
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000262
Dmitri Gribenko65822772012-07-24 21:44:16 +0000263// expected-warning@+3 {{parameter 'a' is already documented}}
264// expected-note@+1 {{previous documentation}}
265/// \param a Aaa.
266/// \param a Aaa.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000267int test_param21(int a);
Dmitri Gribenko65822772012-07-24 21:44:16 +0000268
269// expected-warning@+4 {{parameter 'x2' is already documented}}
270// expected-note@+2 {{previous documentation}}
271/// \param x1 Aaa.
272/// \param x2 Bbb.
273/// \param x2 Ccc.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000274int test_param22(int x1, int x2, int x3);
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000275
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000276// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000277/// \param aaa Meow.
278/// \param bbb Bbb.
279/// \returns aaa.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000280typedef int test_param23(int aaa, int ccc);
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000281
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000282// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000283/// \param aaa Meow.
284/// \param bbb Bbb.
285/// \returns aaa.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000286typedef int (*test_param24)(int aaa, int ccc);
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000287
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000288// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000289/// \param aaa Meow.
290/// \param bbb Bbb.
291/// \returns aaa.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000292typedef int (* const test_param25)(int aaa, int ccc);
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000293
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000294// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
Dmitri Gribenko70ff1092012-08-24 00:05:30 +0000295/// \param aaa Meow.
296/// \param bbb Bbb.
297/// \returns aaa.
Dmitri Gribenko9edd2c82012-08-24 17:45:39 +0000298typedef int (C::*test_param26)(int aaa, int ccc);
299
Dmitri Gribenkoec504e02012-09-15 21:13:36 +0000300typedef int (*test_param27)(int aaa);
301
302// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
303/// \param aaa Meow.
304typedef test_param27 test_param28;
305
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000306
307// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
308/// \tparam T Aaa
309int test_tparam1;
310
311// expected-warning@+1 {{'\tparam' command used in a comment that is not attached to a template declaration}}
312/// \tparam T Aaa
313void test_tparam2(int aaa);
314
315// expected-warning@+1 {{empty paragraph passed to '\tparam' command}}
316/// \tparam
317/// \param aaa Blah blah
318template<typename T>
319void test_tparam3(T aaa);
320
321// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
322/// \tparam T Aaa
323template<typename TT>
324void test_tparam4(TT aaa);
325
326// expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TT'?}}
327/// \tparam T Aaa
328template<typename TT>
329class test_tparam5 {
330 // expected-warning@+1 {{template parameter 'T' not found in the template declaration}} expected-note@+1 {{did you mean 'TTT'?}}
331 /// \tparam T Aaa
332 template<typename TTT>
333 void test_tparam6(TTT aaa);
334};
335
336/// \tparam T1 Aaa
337/// \tparam T2 Bbb
338template<typename T1, typename T2>
339void test_tparam7(T1 aaa, T2 bbb);
340
341// expected-warning@+1 {{template parameter 'SomTy' not found in the template declaration}} expected-note@+1 {{did you mean 'SomeTy'?}}
342/// \tparam SomTy Aaa
343/// \tparam OtherTy Bbb
344template<typename SomeTy, typename OtherTy>
345void test_tparam8(SomeTy aaa, OtherTy bbb);
346
347// expected-warning@+2 {{template parameter 'T1' is already documented}} expected-note@+1 {{previous documentation}}
348/// \tparam T1 Aaa
349/// \tparam T1 Bbb
350template<typename T1, typename T2>
351void test_tparam9(T1 aaa, T2 bbb);
352
353/// \tparam T Aaa
354/// \tparam TT Bbb
355template<template<typename T> class TT>
356void test_tparam10(TT<int> aaa);
357
358/// \tparam T Aaa
359/// \tparam TT Bbb
360/// \tparam TTT Ccc
361template<template<template<typename T> class TT, class C> class TTT>
362void test_tparam11();
363
364/// \tparam I Aaa
365template<int I>
366void test_tparam12();
367
Dmitri Gribenko967e5d72012-08-02 21:36:57 +0000368template<typename T, typename U>
369class test_tparam13 { };
370
371/// \tparam T Aaa
372template<typename T>
373using test_tparam14 = test_tparam13<T, int>;
374
375// expected-warning@+1 {{template parameter 'U' not found in the template declaration}} expected-note@+1 {{did you mean 'T'?}}
376/// \tparam U Aaa
377template<typename T>
378using test_tparam15 = test_tparam13<T, int>;
379
Dmitri Gribenkoabcf0dc2012-09-13 20:36:01 +0000380
381/// Aaa
382/// \deprecated Bbb
Dmitri Gribenko0bd98382012-09-22 21:47:50 +0000383void test_deprecated_1(int a) __attribute__((deprecated));
Dmitri Gribenkoabcf0dc2012-09-13 20:36:01 +0000384
385// We don't want \deprecated to warn about empty paragraph. It is fine to use
386// \deprecated by itself without explanations.
387
388/// Aaa
389/// \deprecated
Dmitri Gribenko0bd98382012-09-22 21:47:50 +0000390void test_deprecated_2(int a) __attribute__((deprecated));
391
392/// Aaa
393/// \deprecated
394void test_deprecated_3(int a) __attribute__((availability(macosx,introduced=10.4)));
395
396/// Aaa
397/// \deprecated
398void test_deprecated_4(int a) __attribute__((unavailable));
399
400// 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}}
401/// Aaa
402/// \deprecated
403void test_deprecated_5(int a);
404
405// 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}}
406/// Aaa
407/// \deprecated
408void test_deprecated_6(int a) {
409}
410
411// expected-warning@+2 {{declaration is marked with '\deprecated' command but does not have a deprecation attribute}}
412/// Aaa
413/// \deprecated
414template<typename T>
415void test_deprecated_7(T aaa);
Dmitri Gribenkoabcf0dc2012-09-13 20:36:01 +0000416
417
Dmitri Gribenko388a5942012-09-14 15:37:29 +0000418/// \invariant aaa
419void test_invariant_1(int a);
420
421// expected-warning@+1 {{empty paragraph passed to '\invariant' command}}
422/// \invariant
423void test_invariant_2(int a);
424
425
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000426// no-warning
427/// \returns Aaa
428int test_returns_right_decl_1(int);
429
430class test_returns_right_decl_2 {
431 // no-warning
432 /// \returns Aaa
433 int test_returns_right_decl_3(int);
434};
435
436// no-warning
437/// \returns Aaa
438template<typename T>
439int test_returns_right_decl_4(T aaa);
440
441// no-warning
442/// \returns Aaa
443template<>
444int test_returns_right_decl_4(int aaa);
445
446/// \returns Aaa
447template<typename T>
448T test_returns_right_decl_5(T aaa);
449
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000450// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000451/// \returns Aaa
452int test_returns_wrong_decl_1;
453
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000454// expected-warning@+1 {{'\return' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000455/// \return Aaa
456int test_returns_wrong_decl_2;
457
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000458// expected-warning@+1 {{'\result' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000459/// \result Aaa
460int test_returns_wrong_decl_3;
461
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000462// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000463/// \returns Aaa
464void test_returns_wrong_decl_4(int);
465
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000466// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000467/// \returns Aaa
468template<typename T>
469void test_returns_wrong_decl_5(T aaa);
470
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000471// expected-warning@+1 {{'\returns' command used in a comment that is attached to a function returning void}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000472/// \returns Aaa
473template<>
474void test_returns_wrong_decl_5(int aaa);
475
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000476// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000477/// \returns Aaa
478struct test_returns_wrong_decl_6 { };
479
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000480// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000481/// \returns Aaa
482class test_returns_wrong_decl_7 {
483 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a constructor}}
484 /// \returns Aaa
485 test_returns_wrong_decl_7();
486
487 // expected-warning@+1 {{'\returns' command used in a comment that is attached to a destructor}}
488 /// \returns Aaa
489 ~test_returns_wrong_decl_7();
490};
491
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000492// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000493/// \returns Aaa
494enum test_returns_wrong_decl_8 {
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000495 // expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000496 /// \returns Aaa
497 test_returns_wrong_decl_9
498};
499
Dmitri Gribenko88815f32012-08-06 16:29:26 +0000500// expected-warning@+1 {{'\returns' command used in a comment that is not attached to a function or method declaration}}
Dmitri Gribenko89ab7d02012-08-03 21:15:32 +0000501/// \returns Aaa
502namespace test_returns_wrong_decl_10 { };
503
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000504
505// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000506int test1; ///< \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000507
508// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
509// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000510int test2, ///< \brief\author Aaa
511 test3; ///< \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000512
513// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
514int test4; ///< \brief
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000515 ///< \author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000516
517
518// Check that we attach the comment to the declaration during parsing in the
519// following cases. The test is based on the fact that we don't parse
520// documentation comments that are not attached to anything.
521
522// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000523/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000524int test_attach1;
525
526// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000527/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000528int test_attach2(int);
529
530// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000531/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000532struct test_attach3 {
533 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000534 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000535 int test_attach4;
536
537 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000538 int test_attach5; ///< \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000539
540 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000541 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000542 int test_attach6(int);
543};
544
545// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000546/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000547class test_attach7 {
548 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000549 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000550 int test_attach8;
551
552 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000553 int test_attach9; ///< \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000554
555 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000556 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000557 int test_attach10(int);
558};
559
560// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000561/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000562enum test_attach9 {
563 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000564 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000565 test_attach10,
566
567 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000568 test_attach11 ///< \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000569};
570
571// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000572/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000573struct test_noattach12 *test_attach13;
574
575// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000576/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000577typedef struct test_noattach14 *test_attach15;
578
579// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000580/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000581typedef struct test_attach16 { int a; } test_attach17;
582
583struct S { int a; };
584
585// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000586/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000587struct S *test_attach18;
588
589// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000590/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000591typedef struct S *test_attach19;
592
593// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000594/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000595struct test_attach20;
596
597// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000598/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000599typedef struct test_attach21 {
600 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000601 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000602 int test_attach22;
603} test_attach23;
604
605// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000606/// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000607namespace test_attach24 {
608 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000609 /// \brief\author Aaa
Dmitri Gribenkoa5ef44f2012-07-11 21:38:39 +0000610 namespace test_attach25 {
611 }
612}
613
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000614// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000615/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000616/// \tparam T Aaa
617template<typename T>
618void test_attach26(T aaa);
619
620// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000621/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000622/// \tparam T Aaa
623template<typename T, typename U>
624void test_attach27(T aaa, U bbb);
625
626// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
627// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000628/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000629/// \tparam T Aaa
630template<>
631void test_attach27(int aaa, int bbb);
632
633// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000634/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000635/// \tparam T Aaa
636template<typename T>
637class test_attach28 {
638 T aaa;
639};
640
641// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000642/// \brief\author Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000643using test_attach29 = test_attach28<int>;
644
645// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000646/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000647/// \tparam T Aaa
648template<typename T, typename U>
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000649class test_attach30 { };
650
651// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000652/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000653/// \tparam T Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000654template<typename T>
655class test_attach30<T, int> { };
656
657// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000658/// \brief\author Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000659template<>
660class test_attach30<int, int> { };
661
662// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000663/// \brief\author Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000664template<typename T>
665using test_attach31 = test_attach30<T, int>;
666
667// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000668/// \brief\author Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000669/// \tparam T Aaa
670template<typename T, typename U, typename V>
671class test_attach32 { };
672
673// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000674/// \brief\author Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000675/// \tparam T Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000676template<typename T, typename U>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000677class test_attach32<T, U, int> { };
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000678
679// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000680/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000681/// \tparam T Aaa
682template<typename T>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000683class test_attach32<T, int, int> { };
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000684
685// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
686// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000687/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000688/// \tparam T Aaa
689template<>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000690class test_attach32<int, int, int> { };
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000691
692// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000693/// \brief\author Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000694class test_attach33 {
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000695 // expected-warning@+1 {{empty paragraph passed to '\brief' command}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000696 /// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000697 /// \tparam T Aaa
698 template<typename T, typename U>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000699 void test_attach34(T aaa, U bbb);
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000700};
701
702template<typename T>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000703class test_attach35 {
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000704 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
705 // expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000706 /// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000707 /// \tparam T Aaa
708 template<typename TT, typename UU>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000709 void test_attach36(TT aaa, UU bbb);
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000710};
711
712// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
713// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000714/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000715/// \tparam T Aaa
716template<> template<>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000717void test_attach35<int>::test_attach36(int aaa, int bbb) {}
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000718
719template<typename T>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000720class test_attach37 {
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000721 // expected-warning@+2 {{empty paragraph passed to '\brief' command}}
722 // expected-warning@+2 {{'\tparam' command used in a comment that is not attached to a template declaration}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000723 /// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000724 /// \tparam T Aaa
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000725 void test_attach38(int aaa, int bbb);
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000726
Dmitri Gribenkoc41ace92012-08-14 17:17:18 +0000727 void test_attach39(int aaa, int bbb);
728};
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000729
730// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
731// expected-warning@+2 {{template parameter 'T' not found in the template declaration}}
Dmitri Gribenko9443c572012-08-06 17:08:27 +0000732/// \brief\author Aaa
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000733/// \tparam T Aaa
734template<>
Dmitri Gribenkoc27bc802012-08-02 20:49:51 +0000735void test_attach37<int>::test_attach38(int aaa, int bbb) {}
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000736
Dmitri Gribenkoc41ace92012-08-14 17:17:18 +0000737// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
738/// \brief\author Aaa
739/// \tparam T Aaa
740template<typename T>
741void test_attach37<T>::test_attach39(int aaa, int bbb) {}
742
Dmitri Gribenko1599eac2012-08-16 18:19:43 +0000743// We used to emit warning that parameter 'a' is not found because we parsed
744// the comment in context of the redeclaration which does not have parameter
745// names.
746template <typename T>
747struct test_attach38 {
748 /*!
749 \param a First param
750 \param b Second param
751 */
752 template <typename B>
753 void test_attach39(T a, B b);
754};
755
756template <>
757template <typename B>
758void test_attach38<int>::test_attach39(int, B);
Dmitri Gribenkoc41ace92012-08-14 17:17:18 +0000759
Dmitri Gribenko96b09862012-07-31 22:37:06 +0000760
Dmitri Gribenko9f08f492012-07-20 20:18:53 +0000761// PR13411, reduced. We used to crash on this.
762/**
763 * @code Aaa.
764 */
765void test_nocrash1(int);
766
Dmitri Gribenkoe5deb792012-07-30 18:05:28 +0000767// We used to crash on this.
768// expected-warning@+2 {{empty paragraph passed to '\param' command}}
769// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
770/// \param\brief
771void test_nocrash2(int);
772
Dmitri Gribenkoc41ace92012-08-14 17:17:18 +0000773// PR13593, example 1 and 2
Douglas Gregorcd81df22012-08-13 16:37:30 +0000774
775/**
776* Bla.
777*/
778template <typename>
779void test_nocrash3();
780
781/// Foo
782template <typename, typename>
783void test_nocrash4() { }
784
785template <typename>
786void test_nocrash3()
787{
788}
Dmitri Gribenkoc41ace92012-08-14 17:17:18 +0000789
790// PR13593, example 3
791
792/**
793 * aaa
794 */
795template <typename T>
796inline T test_nocrash5(T a1)
797{
798 return a1;
799}
800
801///
802//,
803
804inline void test_nocrash6()
805{
806 test_nocrash5(1);
807}
808
809// We used to crash on this.
810
811/*!
812 Blah.
813*/
814typedef const struct test_nocrash7 * test_nocrash8;
815
Dmitri Gribenkob0b8a962012-09-11 19:22:03 +0000816// We used to crash on this.
817
818/// aaa \unknown aaa \unknown aaa
819int test_nocrash9;
820