xref: /aosp_15_r20/external/clang/test/Sema/warn-documentation.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -Wdocumentation -Wdocumentation-pedantic -verify %s
2*67e74705SXin Li
3*67e74705SXin Li@class NSString;
4*67e74705SXin Li
5*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
6*67e74705SXin Li/// \brief\author Aaa
7*67e74705SXin Li@interface Test1
8*67e74705SXin Li// expected-warning@+2 {{empty paragraph passed to '\brief' command}}
9*67e74705SXin Li/**
10*67e74705SXin Li * \brief\author Aaa
11*67e74705SXin Li * \param aaa Aaa
12*67e74705SXin Li * \param bbb Bbb
13*67e74705SXin Li */
14*67e74705SXin Li+ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb;
15*67e74705SXin Li
16*67e74705SXin Li// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'aaa'?}}
17*67e74705SXin Li/**
18*67e74705SXin Li * \param aab Aaa
19*67e74705SXin Li */
20*67e74705SXin Li+ (NSString *)test2:(NSString *)aaa;
21*67e74705SXin Li
22*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
23*67e74705SXin Li/// \brief\author Aaa
24*67e74705SXin Li@property int test3; // a property: ObjCPropertyDecl
25*67e74705SXin Li
26*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
27*67e74705SXin Li/// \brief\author Aaa
28*67e74705SXin Li@property int test4; // a property: ObjCPropertyDecl
29*67e74705SXin Li@end
30*67e74705SXin Li
31*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
32*67e74705SXin Li/// \brief\author Aaa
33*67e74705SXin Li@interface Test1()
34*67e74705SXin Li@end
35*67e74705SXin Li
36*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
37*67e74705SXin Li/// \brief\author Aaa
38*67e74705SXin Li@implementation Test1 // a class implementation : ObjCImplementationDecl
39*67e74705SXin Li+ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb {
40*67e74705SXin Li  return 0;
41*67e74705SXin Li}
42*67e74705SXin Li
43*67e74705SXin Li+ (NSString *)test2:(NSString *)aaa {
44*67e74705SXin Li  return 0;
45*67e74705SXin Li}
46*67e74705SXin Li
47*67e74705SXin Li@synthesize test3; // a property implementation: ObjCPropertyImplDecl
48*67e74705SXin Li@dynamic test4; // a property implementation: ObjCPropertyImplDecl
49*67e74705SXin Li
50*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
51*67e74705SXin Li/// \brief\author Aaa
52*67e74705SXin LiNSString *_test5;
53*67e74705SXin Li@end
54*67e74705SXin Li
55*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
56*67e74705SXin Li/// \brief\author Aaa
57*67e74705SXin Li@interface Test1(Test1Category) // a category: ObjCCategoryDecl
58*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
59*67e74705SXin Li/// \brief\author Aaa
60*67e74705SXin Li+ (NSString *)test3:(NSString *)aaa;
61*67e74705SXin Li@end
62*67e74705SXin Li
63*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
64*67e74705SXin Li/// \brief\author Aaa
65*67e74705SXin Li@implementation Test1(Test1Category) // a category implementation: ObjCCategoryImplDecl
66*67e74705SXin Li+ (NSString *)test3:(NSString *)aaa {
67*67e74705SXin Li  return 0;
68*67e74705SXin Li}
69*67e74705SXin Li@end
70*67e74705SXin Li
71*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
72*67e74705SXin Li/// \brief\author Aaa
73*67e74705SXin Li@protocol TestProto1 // a protocol: ObjCProtocolDecl
74*67e74705SXin Li@end
75*67e74705SXin Li
76*67e74705SXin Liint a;
77*67e74705SXin Li
78*67e74705SXin Li// expected-warning@+1 {{empty paragraph passed to '\brief' command}}
79*67e74705SXin Li/// \brief\author Aaa
80*67e74705SXin Li@interface Test4
81*67e74705SXin Li@end
82*67e74705SXin Li
83*67e74705SXin Liint b;
84*67e74705SXin Li
85*67e74705SXin Li@interface TestReturns1
86*67e74705SXin Li/// \returns Aaa
87*67e74705SXin Li- (int)test1:(NSString *)aaa;
88*67e74705SXin Li
89*67e74705SXin Li// expected-warning@+1 {{'\returns' command used in a comment that is attached to a method returning void}}
90*67e74705SXin Li/// \returns Aaa
91*67e74705SXin Li- (void)test2:(NSString *)aaa;
92*67e74705SXin Li@end
93*67e74705SXin Li
94*67e74705SXin Li// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
95*67e74705SXin Li/// \param aaa Meow.
96*67e74705SXin Li/// \param bbb Bbb.
97*67e74705SXin Li/// \returns aaa.
98*67e74705SXin Litypedef int (^test_param1)(int aaa, int ccc);
99*67e74705SXin Li
100*67e74705SXin Li// rdar://13094352
101*67e74705SXin Li// expected-warning@+2 {{'@method' command should be used in a comment attached to an Objective-C method declaration}}
102*67e74705SXin Li@interface I
103*67e74705SXin Li/*!	@method Base64EncodeEx
104*67e74705SXin Li*/
105*67e74705SXin Litypedef id ID;
106*67e74705SXin Li- (unsigned) Base64EncodeEx : (ID)Arg;
107*67e74705SXin Li@end
108*67e74705SXin Li
109*67e74705SXin Li// rdar://12379114
110*67e74705SXin Li// expected-warning@+5 {{'@interface' command should not be used in a comment attached to a non-interface declaration}}
111*67e74705SXin Li// expected-warning@+5 {{'@classdesign' command should not be used in a comment attached to a non-container declaration}}
112*67e74705SXin Li// expected-warning@+5 {{'@coclass' command should not be used in a comment attached to a non-container declaration}}
113*67e74705SXin Li@interface NSObject @end
114*67e74705SXin Li/*!
115*67e74705SXin Li@interface IOCommandGate
116*67e74705SXin Li@classdesign Multiple paragraphs go here.
117*67e74705SXin Li@coclass myCoClass
118*67e74705SXin Li*/
119*67e74705SXin Li
120*67e74705SXin Litypedef id OBJ;
121*67e74705SXin Li@interface IOCommandGate : NSObject {
122*67e74705SXin Li  OBJ iv;
123*67e74705SXin Li}
124*67e74705SXin Li@end
125*67e74705SXin Li
126*67e74705SXin Li// rdar://12379114
127*67e74705SXin Li// expected-warning@+4 {{'@methodgroup' command should be used in a comment attached to an Objective-C method declaration}}
128*67e74705SXin Li// expected-warning@+6 {{'@method' command should be used in a comment attached to an Objective-C method declaratio}}
129*67e74705SXin Li@interface rdar12379114
130*67e74705SXin Li/*!
131*67e74705SXin Li @methodgroup Creating a request
132*67e74705SXin Li*/
133*67e74705SXin Li/*!
134*67e74705SXin Li @method initWithTimeout is the 2nd method
135*67e74705SXin Li*/
136*67e74705SXin Litypedef unsigned int NSTimeInterval;
137*67e74705SXin Li- (id)initWithTimeout:(NSTimeInterval)timeout;
138*67e74705SXin Li@end
139*67e74705SXin Li
140*67e74705SXin Li// expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}
141*67e74705SXin Li/*!
142*67e74705SXin Li@protocol PROTO
143*67e74705SXin Li*/
144*67e74705SXin Listruct S;
145*67e74705SXin Li
146*67e74705SXin Li/*!
147*67e74705SXin Li  @interface NSArray This is an array
148*67e74705SXin Li*/
149*67e74705SXin Li@class NSArray;
150*67e74705SXin Li@interface NSArray @end
151*67e74705SXin Li
152*67e74705SXin Li// expected-warning@+3 {{unknown command tag name}}
153*67e74705SXin Li/*!
154*67e74705SXin Li@interface NSMutableArray
155*67e74705SXin Li@super NSArray
156*67e74705SXin Li*/
157*67e74705SXin Li@interface NSMutableArray : NSArray @end
158*67e74705SXin Li
159*67e74705SXin Li/*!
160*67e74705SXin Li  @protocol MyProto
161*67e74705SXin Li*/
162*67e74705SXin Li@protocol MyProto @end
163*67e74705SXin Li
164*67e74705SXin Li// expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}
165*67e74705SXin Li/*!
166*67e74705SXin Li @protocol MyProto
167*67e74705SXin Li*/
168*67e74705SXin Li@interface INTF <MyProto> @end
169*67e74705SXin Li
170*67e74705SXin Li// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}
171*67e74705SXin Li/*!
172*67e74705SXin Li  @struct S1 THIS IS IT
173*67e74705SXin Li*/
174*67e74705SXin Li@interface S1 @end
175*67e74705SXin Li
176*67e74705SXin Li// expected-warning@+1 {{unknown command tag name}}
177*67e74705SXin Li/// \t bbb IS_DOXYGEN_END
178*67e74705SXin Liint FooBar();
179*67e74705SXin Li
180*67e74705SXin Li// rdar://13836387
181*67e74705SXin Li/** \brief Module handling the incoming notifications from the system.
182*67e74705SXin Li *
183*67e74705SXin Li * This includes:
184*67e74705SXin Li * - Network Reachability
185*67e74705SXin Li * - Power State
186*67e74705SXin Li * - Low Disk
187*67e74705SXin Li */
188*67e74705SXin Li@interface BRC : NSObject
189*67e74705SXin Li- (void)removeReach:(NSObject*)observer;
190*67e74705SXin Li@end
191*67e74705SXin Li
192*67e74705SXin Li@implementation BRC : NSObject
193*67e74705SXin Li- (void)removeReach:(NSObject*)observer // expected-note {{previous declaration is here}}
194*67e74705SXin Li{
195*67e74705SXin Li}
196*67e74705SXin Li- (void)removeReach:(NSObject*)observer // expected-error {{duplicate declaration of method 'removeReach:'}}
197*67e74705SXin Li{
198*67e74705SXin Li}
199*67e74705SXin Li@end
200*67e74705SXin Li
201*67e74705SXin Li// rdar://13927330
202*67e74705SXin Li/// @class Asset  <- '@class' may be used in a comment attached to a an interface declaration
203*67e74705SXin Li@interface Asset : NSObject
204*67e74705SXin Li@end
205*67e74705SXin Li
206*67e74705SXin Li// rdar://14024851 Check that this does not enter an infinite loop
207*67e74705SXin Li@interface rdar14024851
208*67e74705SXin Li-(void)meth; // expected-note {{declared here}}
209*67e74705SXin Li@end
210*67e74705SXin Li
211*67e74705SXin Li@implementation rdar14024851 // expected-warning {{method definition for 'meth' not found}} expected-note {{previous definition}}
212*67e74705SXin Li@end
213*67e74705SXin Li
214*67e74705SXin Li@implementation rdar14024851 // expected-error {{reimplementation}}
215*67e74705SXin Li/// \brief comment
216*67e74705SXin Li-(void)meth {}
217*67e74705SXin Li@end
218*67e74705SXin Li
219*67e74705SXin Li// rdar://14124644
220*67e74705SXin Li@interface test_vararg1
221*67e74705SXin Li/// @param[in] arg somthing
222*67e74705SXin Li/// @param[in] ... This is vararg
223*67e74705SXin Li- (void) VarArgMeth : (id)arg, ...;
224*67e74705SXin Li@end
225*67e74705SXin Li
226*67e74705SXin Li@implementation test_vararg1
227*67e74705SXin Li/// @param[in] arg somthing
228*67e74705SXin Li/// @param[in] ... This is vararg
229*67e74705SXin Li- (void) VarArgMeth : (id)arg, ... {}
230*67e74705SXin Li@end
231*67e74705SXin Li
232