324 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -fblocks -Wno-objc-root-class -Wdocumentation -Wdocumentation-pedantic -verify %s2// RUN: %clang_cc1 -xobjective-c++ -fsyntax-only -fblocks -Wno-objc-root-class -Wdocumentation -Wdocumentation-pedantic -verify %s3 4@class NSString;5 6// expected-warning@+1 {{empty paragraph passed to '\brief' command}}7/// \brief\author Aaa8@interface Test19// expected-warning@+2 {{empty paragraph passed to '\brief' command}}10/**11 * \brief\author Aaa12 * \param aaa Aaa13 * \param bbb Bbb14 */15+ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb;16 17// expected-warning@+2 {{parameter 'aab' not found in the function declaration}} expected-note@+2 {{did you mean 'aaa'?}}18/**19 * \param aab Aaa20 */21+ (NSString *)test2:(NSString *)aaa;22 23// expected-warning@+1 {{empty paragraph passed to '\brief' command}}24/// \brief\author Aaa25@property int test3; // a property: ObjCPropertyDecl26 27// expected-warning@+1 {{empty paragraph passed to '\brief' command}}28/// \brief\author Aaa29@property int test4; // a property: ObjCPropertyDecl30@end31 32// expected-warning@+1 {{empty paragraph passed to '\brief' command}}33/// \brief\author Aaa34@interface Test1()35@end36 37// expected-warning@+1 {{empty paragraph passed to '\brief' command}}38/// \brief\author Aaa39@implementation Test1 // a class implementation : ObjCImplementationDecl40+ (NSString *)test1:(NSString *)aaa suffix:(NSString *)bbb {41 return 0;42}43 44+ (NSString *)test2:(NSString *)aaa {45 return 0;46}47 48@synthesize test3; // a property implementation: ObjCPropertyImplDecl49@dynamic test4; // a property implementation: ObjCPropertyImplDecl50 51// expected-warning@+1 {{empty paragraph passed to '\brief' command}}52/// \brief\author Aaa53NSString *_test5;54@end55 56// expected-warning@+1 {{empty paragraph passed to '\brief' command}}57/// \brief\author Aaa58@interface Test1(Test1Category) // a category: ObjCCategoryDecl59// expected-warning@+1 {{empty paragraph passed to '\brief' command}}60/// \brief\author Aaa61+ (NSString *)test3:(NSString *)aaa;62@end63 64// expected-warning@+1 {{empty paragraph passed to '\brief' command}}65/// \brief\author Aaa66@implementation Test1(Test1Category) // a category implementation: ObjCCategoryImplDecl67+ (NSString *)test3:(NSString *)aaa {68 return 0;69}70@end71 72// expected-warning@+1 {{empty paragraph passed to '\brief' command}}73/// \brief\author Aaa74@protocol TestProto1 // a protocol: ObjCProtocolDecl75@end76 77int a;78 79// expected-warning@+1 {{empty paragraph passed to '\brief' command}}80/// \brief\author Aaa81@interface Test482@end83 84int b;85 86@interface TestReturns187/// \returns Aaa88- (int)test1:(NSString *)aaa;89 90// expected-warning@+1 {{'\returns' command used in a comment that is attached to a method returning void}}91/// \returns Aaa92- (void)test2:(NSString *)aaa;93@end94 95// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}96/// \param aaa Meow.97/// \param bbb Bbb.98/// \returns aaa.99typedef int (^test_param1)(int aaa, int ccc);100 101// expected-warning@+2 {{'@method' command should be used in a comment attached to an Objective-C method declaration}}102@interface I103/*! @method Base64EncodeEx104*/105typedef id ID;106- (unsigned) Base64EncodeEx : (ID)Arg;107@end108 109// expected-warning@+5 {{'@interface' command should not be used in a comment attached to a non-interface declaration}} 110// expected-warning@+5 {{'@classdesign' command should not be used in a comment attached to a non-container declaration}}111// expected-warning@+5 {{'@coclass' command should not be used in a comment attached to a non-container declaration}} 112@interface NSObject @end113/*!114@interface IOCommandGate115@classdesign Multiple paragraphs go here.116@coclass myCoClass 117*/118 119typedef id OBJ;120@interface IOCommandGate : NSObject {121 OBJ iv;122}123@end124 125// expected-warning@+4 {{'@methodgroup' command should be used in a comment attached to an Objective-C method declaration}}126// expected-warning@+6 {{'@method' command should be used in a comment attached to an Objective-C method declaratio}}127@interface rdar12379114128/*!129 @methodgroup Creating a request130*/131/*!132 @method initWithTimeout is the 2nd method133*/134typedef unsigned int NSTimeInterval;135- (id)initWithTimeout:(NSTimeInterval)timeout;136@end137 138// expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}139/*!140@protocol PROTO141*/142struct S;143 144/*!145 @interface NSArray This is an array146*/147@class NSArray;148@interface NSArray @end149 150// expected-warning@+3 {{unknown command tag name}}151/*!152@interface NSMutableArray 153@super NSArray154*/155@interface NSMutableArray : NSArray @end156 157/*!158 @protocol MyProto159*/160@protocol MyProto @end161 162// expected-warning@+2 {{'@protocol' command should not be used in a comment attached to a non-protocol declaration}}163/*!164 @protocol MyProto165*/166@interface INTF <MyProto> @end167 168// expected-warning@+2 {{'@struct' command should not be used in a comment attached to a non-struct declaration}}169/*!170 @struct S1 THIS IS IT171*/172@interface S1 @end173 174// expected-warning@+1 {{unknown command tag name}}175/// \t bbb IS_DOXYGEN_END176int FooBar(void);177 178/** \brief Module handling the incoming notifications from the system.179 *180 * This includes:181 * - Network Reachability182 * - Power State183 * - Low Disk184 */185@interface BRC : NSObject186- (void)removeReach:(NSObject*)observer;187@end188 189@implementation BRC : NSObject190- (void)removeReach:(NSObject*)observer // expected-note {{previous declaration is here}}191{192}193- (void)removeReach:(NSObject*)observer // expected-error {{duplicate declaration of method 'removeReach:'}}194{195}196@end197 198/// @class Asset <- '@class' may be used in a comment attached to a an interface declaration199@interface Asset : NSObject200@end201 202// Check that this does not enter an infinite loop203@interface rdar14024851204-(void)meth; // expected-note {{declared here}}205@end206 207@implementation rdar14024851 // expected-warning {{method definition for 'meth' not found}} expected-note {{previous definition}}208@end209 210@implementation rdar14024851 // expected-error {{reimplementation}}211/// \brief comment212-(void)meth {}213@end214 215@interface test_vararg1216/// @param[in] arg something217/// @param[in] ... This is vararg218- (void) VarArgMeth : (id)arg, ...;219@end220 221@implementation test_vararg1222/// @param[in] arg something223/// @param[in] ... This is vararg224- (void) VarArgMeth : (id)arg, ... {}225@end226 227/**228 * blockPointerVariable229 *230 * @param i is integer.231 * @returns integer.232 */233int (^blockPointerVariable)(int i);234 235struct HasFields {236 /**237 * blockPointerField238 *239 * \param i is integer.240 * \returns integer.241 */242 int (^blockPointerFields)(int i);243};244 245// expected-warning@+5 {{parameter 'p' not found in the function declaration}}246// expected-warning@+5 {{'\returns' command used in a comment that is attached to a function returning void}}247/**248 * functionPointerVariable249 *250 * \param p not here.251 * \returns integer.252 */253void (^_Nullable blockPointerVariableThatLeadsNowhere)(void);254 255@interface CheckFunctionBlockPointerVars {256 /**257 * functionPointerIVar258 *259 * @param i is integer.260 * @returns integer.261 */262 int (*functionPointerIVar)(int i);263 264 /**265 * blockPointerIVar266 *267 * \param i is integer.268 * \returns integer.269 */270 int (^blockPointerIVar)(int i);271}272 273/**274 * functionPointerProperty275 *276 * @param i is integer.277 * @returns integer.278 */279@property int (*functionPointerProperty)(int i);280 281/**282 * blockPointerProperty283 *284 * \param i is integer.285 * \returns integer.286 */287@property int (^blockPointerProperty)(int i);288 289/**290 * blockReturnsNothing291 *292 * \returns Nothing, but can allow this as this pattern is used to document the293 * value that the property getter returns.294 */295@property void (^blockReturnsNothing)(void);296 297@end298 299/*!300 * Block typedef with variadic params.301 *302 * @param a303 * works304 *305 * @param ...306 * now should work too.307 */308typedef void (^VariadicBlockType)(int a, ...);309 310// PR42844 - Assertion failures when using typedefed block pointers311typedef void(^VoidBlockType)(void);312typedef VoidBlockType VoidBlockTypeCall(void);313VoidBlockTypeCall *d; ///< \return none314// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}315VoidBlockTypeCall ^e; ///< \return none316// expected-warning@-1 {{'\return' command used in a comment that is not attached to a function or method declaration}}317 318#ifdef __cplusplus319@interface HasAnonNamespace @end320@implementation HasAnonNamespace321namespace {}322@end323#endif324