1f4a2713aSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s 2f4a2713aSLionel Sambuc 3f4a2713aSLionel Sambuc@interface NSString @end 4f4a2713aSLionel Sambuc 5f4a2713aSLionel Sambuc@interface NSObject @end 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc@interface SynthItAll 8f4a2713aSLionel Sambuc@property int howMany; 9f4a2713aSLionel Sambuc@property (retain) NSString* what; 10f4a2713aSLionel Sambuc@end 11f4a2713aSLionel Sambuc 12f4a2713aSLionel Sambuc@implementation SynthItAll 13f4a2713aSLionel Sambuc#if !__has_feature(objc_default_synthesize_properties) 14f4a2713aSLionel Sambuc@synthesize howMany, what; 15f4a2713aSLionel Sambuc#endif 16f4a2713aSLionel Sambuc@end 17f4a2713aSLionel Sambuc 18f4a2713aSLionel Sambuc 19f4a2713aSLionel Sambuc@interface SynthSetter : NSObject 20f4a2713aSLionel Sambuc@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair 21f4a2713aSLionel Sambuc@property (nonatomic, retain) NSString* what; 22f4a2713aSLionel Sambuc@end 23f4a2713aSLionel Sambuc 24f4a2713aSLionel Sambuc@implementation SynthSetter 25f4a2713aSLionel Sambuc#if !__has_feature(objc_default_synthesize_properties) 26f4a2713aSLionel Sambuc@synthesize howMany, what; 27f4a2713aSLionel Sambuc#endif 28f4a2713aSLionel Sambuc 29f4a2713aSLionel Sambuc- (int) howMany { 30f4a2713aSLionel Sambuc return self.howMany; 31f4a2713aSLionel Sambuc} 32f4a2713aSLionel Sambuc// - (void) setHowMany: (int) value 33f4a2713aSLionel Sambuc 34f4a2713aSLionel Sambuc- (NSString*) what { 35f4a2713aSLionel Sambuc return self.what; 36f4a2713aSLionel Sambuc} 37f4a2713aSLionel Sambuc// - (void) setWhat: (NSString*) value 38f4a2713aSLionel Sambuc@end 39f4a2713aSLionel Sambuc 40f4a2713aSLionel Sambuc 41f4a2713aSLionel Sambuc@interface SynthGetter : NSObject 42f4a2713aSLionel Sambuc@property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair 43f4a2713aSLionel Sambuc@property (nonatomic, retain) NSString* what; 44f4a2713aSLionel Sambuc@end 45f4a2713aSLionel Sambuc 46f4a2713aSLionel Sambuc@implementation SynthGetter 47f4a2713aSLionel Sambuc#if !__has_feature(objc_default_synthesize_properties) 48f4a2713aSLionel Sambuc@synthesize howMany, what; 49f4a2713aSLionel Sambuc#endif 50f4a2713aSLionel Sambuc 51f4a2713aSLionel Sambuc// - (int) howMany 52f4a2713aSLionel Sambuc- (void) setHowMany: (int) value { 53f4a2713aSLionel Sambuc self.howMany = value; 54f4a2713aSLionel Sambuc} 55f4a2713aSLionel Sambuc 56f4a2713aSLionel Sambuc// - (NSString*) what 57f4a2713aSLionel Sambuc- (void) setWhat: (NSString*) value { 58f4a2713aSLionel Sambuc if (self.what != value) { 59f4a2713aSLionel Sambuc } 60f4a2713aSLionel Sambuc} 61f4a2713aSLionel Sambuc@end 62f4a2713aSLionel Sambuc 63f4a2713aSLionel Sambuc 64f4a2713aSLionel Sambuc@interface SynthNone : NSObject 65f4a2713aSLionel Sambuc@property int howMany; 66f4a2713aSLionel Sambuc@property (retain) NSString* what; 67f4a2713aSLionel Sambuc@end 68f4a2713aSLionel Sambuc 69f4a2713aSLionel Sambuc@implementation SynthNone 70f4a2713aSLionel Sambuc#if !__has_feature(objc_default_synthesize_properties) 71f4a2713aSLionel Sambuc@synthesize howMany, what; // REM: Redundant anyway 72f4a2713aSLionel Sambuc#endif 73f4a2713aSLionel Sambuc 74f4a2713aSLionel Sambuc- (int) howMany { 75f4a2713aSLionel Sambuc return self.howMany; 76f4a2713aSLionel Sambuc} 77f4a2713aSLionel Sambuc- (void) setHowMany: (int) value { 78f4a2713aSLionel Sambuc self.howMany = value; 79f4a2713aSLionel Sambuc} 80f4a2713aSLionel Sambuc 81f4a2713aSLionel Sambuc- (NSString*) what { 82f4a2713aSLionel Sambuc return self.what; 83f4a2713aSLionel Sambuc} 84f4a2713aSLionel Sambuc- (void) setWhat: (NSString*) value { 85f4a2713aSLionel Sambuc if (self.what != value) { 86f4a2713aSLionel Sambuc } 87f4a2713aSLionel Sambuc} 88f4a2713aSLionel Sambuc@end 89f4a2713aSLionel Sambuc 90f4a2713aSLionel Sambuc@protocol TopProtocol 91f4a2713aSLionel Sambuc @property (readonly) id myString; 92f4a2713aSLionel Sambuc@end 93f4a2713aSLionel Sambuc 94f4a2713aSLionel Sambuc@interface TopClass <TopProtocol> 95f4a2713aSLionel Sambuc{ 96f4a2713aSLionel Sambuc id myString; 97f4a2713aSLionel Sambuc} 98f4a2713aSLionel Sambuc@end 99f4a2713aSLionel Sambuc 100f4a2713aSLionel Sambuc@interface SubClass : TopClass <TopProtocol> 101f4a2713aSLionel Sambuc@end 102f4a2713aSLionel Sambuc 103f4a2713aSLionel Sambuc@implementation SubClass @end 104f4a2713aSLionel Sambuc 105f4a2713aSLionel Sambuc// rdar://7920807 106f4a2713aSLionel Sambuc@interface C @end 107f4a2713aSLionel Sambuc@interface C (Category) 108f4a2713aSLionel Sambuc@property int p; // expected-note 2 {{property declared here}} 109f4a2713aSLionel Sambuc@end 110f4a2713aSLionel Sambuc@implementation C (Category) // expected-warning {{property 'p' requires method 'p' to be defined}} \ 111f4a2713aSLionel Sambuc // expected-warning {{property 'p' requires method 'setP:' to be defined}} 112f4a2713aSLionel Sambuc@end 113f4a2713aSLionel Sambuc 114f4a2713aSLionel Sambuc// Don't complain if a property is already @synthesized by usr. 115f4a2713aSLionel Sambuc@interface D 116f4a2713aSLionel Sambuc{ 117f4a2713aSLionel Sambuc} 118f4a2713aSLionel Sambuc@property int PROP; 119f4a2713aSLionel Sambuc@end 120f4a2713aSLionel Sambuc 121f4a2713aSLionel Sambuc@implementation D 122f4a2713aSLionel Sambuc- (int) Meth { return self.PROP; } 123f4a2713aSLionel Sambuc#if __has_feature(objc_default_synthesize_properties) 124f4a2713aSLionel Sambuc@synthesize PROP=IVAR; 125f4a2713aSLionel Sambuc#endif 126f4a2713aSLionel Sambuc@end 127f4a2713aSLionel Sambuc 128f4a2713aSLionel Sambuc// rdar://10567333 129f4a2713aSLionel Sambuc@protocol MyProtocol 130f4a2713aSLionel Sambuc@property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}} 131f4a2713aSLionel Sambuc 132f4a2713aSLionel Sambuc@optional 133f4a2713aSLionel Sambuc@property (nonatomic, strong) NSString *optionalString; 134f4a2713aSLionel Sambuc@end 135f4a2713aSLionel Sambuc 136f4a2713aSLionel Sambuc@interface MyClass <MyProtocol> 137f4a2713aSLionel Sambuc@end 138f4a2713aSLionel Sambuc 139*0a6a1f1dSLionel Sambuc@implementation MyClass // expected-warning {{auto property synthesis will not synthesize property 'requiredString' declared in protocol 'MyProtocol'}} 140*0a6a1f1dSLionel Sambuc@end 141*0a6a1f1dSLionel Sambuc 142*0a6a1f1dSLionel Sambuc// rdar://18152478 143*0a6a1f1dSLionel Sambuc@protocol NSObject @end 144*0a6a1f1dSLionel Sambuc@protocol TMSourceManagerDelegate<NSObject> 145*0a6a1f1dSLionel Sambuc@end 146*0a6a1f1dSLionel Sambuc 147*0a6a1f1dSLionel Sambuc@protocol TMSourceManager <NSObject> 148*0a6a1f1dSLionel Sambuc@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate; 149*0a6a1f1dSLionel Sambuc@end 150*0a6a1f1dSLionel Sambuc 151*0a6a1f1dSLionel Sambuc@interface TMSourceManager 152*0a6a1f1dSLionel Sambuc@property (nonatomic, assign) id <TMSourceManagerDelegate> delegate; 153*0a6a1f1dSLionel Sambuc@end 154*0a6a1f1dSLionel Sambuc 155*0a6a1f1dSLionel Sambuc@protocol TMTimeZoneManager <TMSourceManager> 156*0a6a1f1dSLionel Sambuc@end 157*0a6a1f1dSLionel Sambuc 158*0a6a1f1dSLionel Sambuc@interface TimeZoneManager : TMSourceManager <TMTimeZoneManager> 159*0a6a1f1dSLionel Sambuc@end 160*0a6a1f1dSLionel Sambuc 161*0a6a1f1dSLionel Sambuc@implementation TimeZoneManager 162*0a6a1f1dSLionel Sambuc@end 163*0a6a1f1dSLionel Sambuc 164*0a6a1f1dSLionel Sambuc// rdar://18179833 165*0a6a1f1dSLionel Sambuc@protocol BaseProt 166*0a6a1f1dSLionel Sambuc@property (assign) id prot; 167*0a6a1f1dSLionel Sambuc@end 168*0a6a1f1dSLionel Sambuc 169*0a6a1f1dSLionel Sambuc@interface Base<BaseProt> 170*0a6a1f1dSLionel Sambuc@end 171*0a6a1f1dSLionel Sambuc 172*0a6a1f1dSLionel Sambuc@interface I : Base<BaseProt> 173*0a6a1f1dSLionel Sambuc@end 174*0a6a1f1dSLionel Sambuc 175*0a6a1f1dSLionel Sambuc@implementation I 176f4a2713aSLionel Sambuc@end 177