Fariborz Jahanian | 112c330 | 2011-01-04 20:05:20 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -fobjc-nonfragile-abi -fobjc-default-synthesize-properties -verify %s |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 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 { |
Ted Kremenek | d2ee809 | 2011-09-27 23:39:40 +0000 | [diff] [blame^] | 28 | return _howMany; |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 29 | } |
| 30 | // - (void) setHowMany: (int) value |
| 31 | |
| 32 | - (NSString*) what { |
Ted Kremenek | d2ee809 | 2011-09-27 23:39:40 +0000 | [diff] [blame^] | 33 | return _what; |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 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 { |
Ted Kremenek | d2ee809 | 2011-09-27 23:39:40 +0000 | [diff] [blame^] | 49 | _howMany = value; |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | // - (NSString*) what |
| 53 | - (void) setWhat: (NSString*) value { |
Ted Kremenek | d2ee809 | 2011-09-27 23:39:40 +0000 | [diff] [blame^] | 54 | if (_what != value) { |
| 55 | [_what release]; |
| 56 | _what = [value retain]; |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 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 { |
Fariborz Jahanian | 8697d30 | 2011-08-31 22:24:06 +0000 | [diff] [blame] | 71 | return howMany; // expected-error {{use of undeclared identifier 'howMany'}} |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 72 | } |
| 73 | - (void) setHowMany: (int) value { |
Fariborz Jahanian | 8697d30 | 2011-08-31 22:24:06 +0000 | [diff] [blame] | 74 | howMany = value; // expected-error {{use of undeclared identifier 'howMany'}} |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | - (NSString*) what { |
Fariborz Jahanian | 8697d30 | 2011-08-31 22:24:06 +0000 | [diff] [blame] | 78 | return what; // expected-error {{use of undeclared identifier 'what'}} |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 79 | } |
| 80 | - (void) setWhat: (NSString*) value { |
Fariborz Jahanian | 8697d30 | 2011-08-31 22:24:06 +0000 | [diff] [blame] | 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'}} |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | @end |
| 87 | |
Fariborz Jahanian | 95f1b86 | 2010-08-25 00:31:58 +0000 | [diff] [blame] | 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 |
Fariborz Jahanian | af6c314 | 2010-07-17 01:16:59 +0000 | [diff] [blame] | 116 | |