173 lines · plain
1// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s2 3@interface NSString @end4 5@interface NSObject @end6 7@interface SynthItAll8@property int howMany;9@property (retain) NSString* what;10@end11 12@implementation SynthItAll13#if !__has_feature(objc_default_synthesize_properties)14@synthesize howMany, what;15#endif16@end17 18 19@interface SynthSetter : NSObject20@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair21@property (nonatomic, retain) NSString* what;22@end23 24@implementation SynthSetter25#if !__has_feature(objc_default_synthesize_properties)26@synthesize howMany, what;27#endif28 29- (int) howMany {30 return self.howMany;31}32// - (void) setHowMany: (int) value33 34- (NSString*) what {35 return self.what;36}37// - (void) setWhat: (NSString*) value 38@end39 40 41@interface SynthGetter : NSObject42@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair43@property (nonatomic, retain) NSString* what;44@end45 46@implementation SynthGetter47#if !__has_feature(objc_default_synthesize_properties)48@synthesize howMany, what;49#endif50 51// - (int) howMany52- (void) setHowMany: (int) value {53 self.howMany = value;54}55 56// - (NSString*) what57- (void) setWhat: (NSString*) value {58 if (self.what != value) {59 }60}61@end62 63 64@interface SynthNone : NSObject65@property int howMany;66@property (retain) NSString* what;67@end68 69@implementation SynthNone70#if !__has_feature(objc_default_synthesize_properties)71@synthesize howMany, what; // REM: Redundant anyway72#endif73 74- (int) howMany {75 return self.howMany;76}77- (void) setHowMany: (int) value {78 self.howMany = value;79}80 81- (NSString*) what {82 return self.what;83}84- (void) setWhat: (NSString*) value {85 if (self.what != value) {86 }87}88@end89 90@protocol TopProtocol91 @property (readonly) id myString;92@end93 94@interface TopClass <TopProtocol> 95{96 id myString; 97}98@end99 100@interface SubClass : TopClass <TopProtocol>101@end102 103@implementation SubClass @end104 105@interface C @end106@interface C (Category)107@property int p; // expected-note 2 {{property declared here}}108@end109@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \110 // expected-warning {{property 'p' requires method 'setP:' to be defined}}111@end112 113// Don't complain if a property is already @synthesized by usr.114@interface D115{116}117@property int PROP;118@end119 120@implementation D121- (int) Meth { return self.PROP; }122#if __has_feature(objc_default_synthesize_properties)123@synthesize PROP=IVAR;124#endif125@end126 127@protocol MyProtocol 128@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}}129 130@optional131@property (nonatomic, strong) NSString *optionalString;132@end133 134@interface MyClass <MyProtocol> 135@end136 137@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}}138@end // expected-note {{add a '@synthesize' directive}}139 140@protocol NSObject @end141@protocol TMSourceManagerDelegate<NSObject>142@end143 144@protocol TMSourceManager <NSObject>145@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;146@end147 148@interface TMSourceManager149@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;150@end151 152@protocol TMTimeZoneManager <TMSourceManager>153@end154 155@interface TimeZoneManager : TMSourceManager <TMTimeZoneManager>156@end157 158@implementation TimeZoneManager159@end160 161@protocol BaseProt162@property (assign) id prot;163@end164 165@interface Base<BaseProt>166@end167 168@interface I : Base<BaseProt>169@end170 171@implementation I172@end173