1 // RUN: %clang_cc1 -fsyntax-only -fobjc-default-synthesize-properties -verify -Wno-objc-root-class %s 2 3 @interface NSObject 4 - (void) release; 5 - (id) retain; 6 @end 7 @class NSString; 8 9 @interface SynthItAll : NSObject 10 @property int howMany; 11 @property (retain) NSString* what; 12 @end 13 14 @implementation SynthItAll 15 //@synthesize howMany, what; 16 @end 17 18 19 @interface SynthSetter : NSObject 20 @property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair 21 @property (nonatomic, retain) NSString* what; 22 @end 23 24 @implementation SynthSetter 25 //@synthesize howMany, what; 26 27 - (int) howMany { 28 return _howMany; 29 } 30 // - (void) setHowMany: (int) value 31 32 - (NSString*) what { 33 return _what; 34 } 35 // - (void) setWhat: (NSString*) value 36 @end 37 38 39 @interface SynthGetter : NSObject 40 @property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair 41 @property (nonatomic, retain) NSString* what; 42 @end 43 44 @implementation SynthGetter 45 //@synthesize howMany, what; 46 47 // - (int) howMany 48 - (void) setHowMany: (int) value { 49 _howMany = value; 50 } 51 52 // - (NSString*) what 53 - (void) setWhat: (NSString*) value { 54 if (_what != value) { 55 [_what release]; 56 _what = [value retain]; 57 } 58 } 59 @end 60 61 62 @interface SynthNone : NSObject 63 @property int howMany; 64 @property (retain) NSString* what; 65 @end 66 67 @implementation SynthNone 68 //@synthesize howMany, what; // REM: Redundant anyway 69 70 - (int) howMany { 71 return howMany; // expected-error {{use of undeclared identifier 'howMany'}} 72 } 73 - (void) setHowMany: (int) value { 74 howMany = value; // expected-error {{use of undeclared identifier 'howMany'}} 75 } 76 77 - (NSString*) what { 78 return what; // expected-error {{use of undeclared identifier 'what'}} 79 } 80 - (void) setWhat: (NSString*) value { 81 if (what != value) { // expected-error {{use of undeclared identifier 'what'}} 82 [what release]; // expected-error {{use of undeclared identifier 'what'}} 83 what = [value retain]; // expected-error {{use of undeclared identifier 'what'}} 84 } 85 } 86 @end 87 88 // rdar://8349319 89 // No default synthesis if implementation has getter (readonly) and setter(readwrite) methods. 90 @interface DSATextSearchResult 91 @property(assign,readonly) float relevance; 92 @property(assign,readonly) char isTitleMatch; 93 @end 94 95 @interface DSANodeSearchResult : DSATextSearchResult {} 96 @end 97 98 99 @implementation DSATextSearchResult 100 -(char)isTitleMatch { 101 return (char)0; 102 } 103 104 -(float)relevance { 105 return 0.0; 106 } 107 @end 108 109 @implementation DSANodeSearchResult 110 -(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch { 111 relevance = 0.0; 112 isTitleMatch = 'a'; 113 return self; 114 } 115 @end 116 117