2013-09-28 04:21:48 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
@interface NSString @end
|
|
|
|
|
|
|
|
@interface NSObject @end
|
|
|
|
|
|
|
|
@interface SynthItAll
|
|
|
|
@property int howMany;
|
|
|
|
@property (retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthItAll
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what;
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthSetter : NSObject
|
|
|
|
@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
|
|
|
|
@property (nonatomic, retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthSetter
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what;
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
- (int) howMany {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.howMany;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
// - (void) setHowMany: (int) value
|
|
|
|
|
|
|
|
- (NSString*) what {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.what;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
// - (void) setWhat: (NSString*) value
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthGetter : NSObject
|
|
|
|
@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
|
|
|
|
@property (nonatomic, retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthGetter
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what;
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
// - (int) howMany
|
|
|
|
- (void) setHowMany: (int) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
self.howMany = value;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// - (NSString*) what
|
|
|
|
- (void) setWhat: (NSString*) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
if (self.what != value) {
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
|
|
@interface SynthNone : NSObject
|
|
|
|
@property int howMany;
|
|
|
|
@property (retain) NSString* what;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation SynthNone
|
2012-02-02 08:15:51 +08:00
|
|
|
#if !__has_feature(objc_default_synthesize_properties)
|
|
|
|
@synthesize howMany, what; // REM: Redundant anyway
|
|
|
|
#endif
|
2010-02-10 05:49:50 +08:00
|
|
|
|
|
|
|
- (int) howMany {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.howMany;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
- (void) setHowMany: (int) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
self.howMany = value;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*) what {
|
2010-04-03 04:09:24 +08:00
|
|
|
return self.what;
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
- (void) setWhat: (NSString*) value {
|
2010-04-03 04:09:24 +08:00
|
|
|
if (self.what != value) {
|
2010-02-10 05:49:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2010-04-22 02:57:20 +08:00
|
|
|
@protocol TopProtocol
|
2014-08-30 04:29:31 +08:00
|
|
|
@property (readonly) id myString;
|
2010-04-22 02:57:20 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TopClass <TopProtocol>
|
|
|
|
{
|
2010-05-03 23:49:20 +08:00
|
|
|
id myString;
|
2010-04-22 02:57:20 +08:00
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
2014-07-27 04:52:26 +08:00
|
|
|
@interface SubClass : TopClass <TopProtocol>
|
2010-04-22 02:57:20 +08:00
|
|
|
@end
|
|
|
|
|
2014-08-30 04:29:31 +08:00
|
|
|
@implementation SubClass @end
|
2010-04-30 01:52:18 +08:00
|
|
|
|
2010-11-09 10:16:57 +08:00
|
|
|
// rdar://7920807
|
2010-04-30 01:52:18 +08:00
|
|
|
@interface C @end
|
|
|
|
@interface C (Category)
|
2011-08-28 05:55:47 +08:00
|
|
|
@property int p; // expected-note 2 {{property declared here}}
|
2010-04-30 01:52:18 +08:00
|
|
|
@end
|
2011-08-28 05:55:47 +08:00
|
|
|
@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \
|
|
|
|
// expected-warning {{property 'p' requires method 'setP:' to be defined}}
|
2010-04-30 01:52:18 +08:00
|
|
|
@end
|
|
|
|
|
2010-07-15 02:11:52 +08:00
|
|
|
// Don't complain if a property is already @synthesized by usr.
|
|
|
|
@interface D
|
|
|
|
{
|
|
|
|
}
|
|
|
|
@property int PROP;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation D
|
2011-07-22 09:06:53 +08:00
|
|
|
- (int) Meth { return self.PROP; }
|
2012-02-02 08:15:51 +08:00
|
|
|
#if __has_feature(objc_default_synthesize_properties)
|
2011-08-02 06:39:49 +08:00
|
|
|
@synthesize PROP=IVAR;
|
2012-02-02 08:15:51 +08:00
|
|
|
#endif
|
2010-07-15 02:11:52 +08:00
|
|
|
@end
|
|
|
|
|
2011-12-15 09:03:18 +08:00
|
|
|
// rdar://10567333
|
|
|
|
@protocol MyProtocol
|
|
|
|
@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}}
|
|
|
|
|
|
|
|
@optional
|
|
|
|
@property (nonatomic, strong) NSString *optionalString;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface MyClass <MyProtocol>
|
|
|
|
@end
|
|
|
|
|
2013-12-13 07:40:14 +08:00
|
|
|
@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}}
|
2017-07-03 18:12:24 +08:00
|
|
|
@end // expected-note {{add a '@synthesize' directive}}
|
2014-08-30 02:31:16 +08:00
|
|
|
|
|
|
|
// rdar://18152478
|
|
|
|
@protocol NSObject @end
|
|
|
|
@protocol TMSourceManagerDelegate<NSObject>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol TMSourceManager <NSObject>
|
|
|
|
@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TMSourceManager
|
|
|
|
@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@protocol TMTimeZoneManager <TMSourceManager>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TimeZoneManager : TMSourceManager <TMTimeZoneManager>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation TimeZoneManager
|
|
|
|
@end
|
2014-08-30 04:29:31 +08:00
|
|
|
|
|
|
|
// rdar://18179833
|
|
|
|
@protocol BaseProt
|
|
|
|
@property (assign) id prot;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface Base<BaseProt>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface I : Base<BaseProt>
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation I
|
|
|
|
@end
|