1 | // RUN: %clang_cc1 -fsyntax-only -Wobjc-missing-property-synthesis -verify -Wno-objc-root-class -triple=x86_64-apple-macos10.10 %s |
2 | // rdar://11295716 |
3 | |
4 | @interface NSObject |
5 | - (void) release; |
6 | - (id) retain; |
7 | @end |
8 | @class NSString; |
9 | |
10 | @interface SynthItAll : NSObject |
11 | @property int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
12 | @property (retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
13 | @end |
14 | |
15 | @implementation SynthItAll // expected-note 2 {{detected while default synthesizing properties in class implementation}} |
16 | //@synthesize howMany, what; |
17 | @end |
18 | |
19 | |
20 | @interface SynthSetter : NSObject |
21 | @property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
22 | @property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
23 | @end |
24 | |
25 | @implementation SynthSetter // expected-note 2 {{detected while default synthesizing properties in class implementation}} |
26 | //@synthesize howMany, what; |
27 | |
28 | - (int) howMany { |
29 | return _howMany; |
30 | } |
31 | // - (void) setHowMany: (int) value |
32 | |
33 | - (NSString*) what { |
34 | return _what; |
35 | } |
36 | // - (void) setWhat: (NSString*) value |
37 | @end |
38 | |
39 | |
40 | @interface SynthGetter : NSObject |
41 | @property (nonatomic) int howMany; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
42 | @property (nonatomic, retain) NSString* what; // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
43 | @end |
44 | |
45 | @implementation SynthGetter // expected-note 2 {{detected while default synthesizing properties in class implementation}} |
46 | //@synthesize howMany, what; |
47 | |
48 | // - (int) howMany |
49 | - (void) setHowMany: (int) value { |
50 | _howMany = value; |
51 | } |
52 | |
53 | // - (NSString*) what |
54 | - (void) setWhat: (NSString*) value { |
55 | if (_what != value) { |
56 | [_what release]; |
57 | _what = [value retain]; |
58 | } |
59 | } |
60 | @end |
61 | |
62 | |
63 | @interface SynthNone : NSObject |
64 | @property int howMany; |
65 | @property (retain) NSString* what; |
66 | @end |
67 | |
68 | @implementation SynthNone |
69 | //@synthesize howMany, what; // REM: Redundant anyway |
70 | |
71 | - (int) howMany { |
72 | return howMany; // expected-error {{use of undeclared identifier 'howMany'}} |
73 | } |
74 | - (void) setHowMany: (int) value { |
75 | howMany = value; // expected-error {{use of undeclared identifier 'howMany'}} |
76 | } |
77 | |
78 | - (NSString*) what { |
79 | return what; // expected-error {{use of undeclared identifier 'what'}} |
80 | } |
81 | - (void) setWhat: (NSString*) value { |
82 | if (what != value) { // expected-error {{use of undeclared identifier 'what'}} |
83 | [what release]; // expected-error {{use of undeclared identifier 'what'}} |
84 | what = [value retain]; // expected-error {{use of undeclared identifier 'what'}} |
85 | } |
86 | } |
87 | @end |
88 | |
89 | // rdar://8349319 |
90 | // No default synthesis if implementation has getter (readonly) and setter(readwrite) methods. |
91 | @interface DSATextSearchResult |
92 | @property(assign,readonly) float relevance; |
93 | @property(assign,readonly) char isTitleMatch; |
94 | @end |
95 | |
96 | @interface DSANodeSearchResult : DSATextSearchResult {} |
97 | @end |
98 | |
99 | |
100 | @implementation DSATextSearchResult |
101 | -(char)isTitleMatch { |
102 | return (char)0; |
103 | } |
104 | |
105 | -(float)relevance { |
106 | return 0.0; |
107 | } |
108 | @end |
109 | |
110 | @implementation DSANodeSearchResult |
111 | -(id)initWithNode:(id )node relevance:(float)relevance isTitleMatch:(char)isTitleMatch { |
112 | relevance = 0.0; |
113 | isTitleMatch = 'a'; |
114 | return self; |
115 | } |
116 | @end |
117 | |
118 | @interface rdar11333367 |
119 | @property enum A x; // expected-note {{forward declaration of 'enum A'}} expected-note {{property declared here}} |
120 | @property struct B y; // expected-note {{forward declaration of 'struct B'}} expected-note {{property declared here}} \ |
121 | // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
122 | @end |
123 | @implementation rdar11333367 // expected-error {{cannot synthesize property 'y' with incomplete type 'struct B'}} \ |
124 | // expected-note {{detected while default synthesizing properties in class implementation}} |
125 | @synthesize x; // expected-error {{cannot synthesize property 'x' with incomplete type 'enum A'}} |
126 | @end |
127 | |
128 | // rdar://17774815 |
129 | @interface ZXParsedResult |
130 | @property (nonatomic, copy, readonly) NSString *description; // expected-note {{property declared here}} |
131 | @end |
132 | |
133 | @interface ZXCalendarParsedResult : ZXParsedResult |
134 | |
135 | @property (nonatomic, copy, readonly) NSString *description; // expected-warning {{auto property synthesis will not synthesize property 'description'; it will be implemented by its superclass}} |
136 | |
137 | @end |
138 | |
139 | @implementation ZXCalendarParsedResult // expected-note {{detected while default synthesizing properties in class implementation}} |
140 | - (NSString *) Meth { |
141 | return _description; // expected-error {{use of undeclared identifier '_description'}} |
142 | } |
143 | @end |
144 | |
145 | @interface DontWarnOnUnavailable |
146 | |
147 | // No warning expected: |
148 | @property (nonatomic, readonly) int un1 __attribute__((unavailable)); |
149 | @property (readwrite) int un2 __attribute__((availability(macos, unavailable))); |
150 | |
151 | @property (readwrite) int un3 __attribute__((availability(ios, unavailable))); // expected-warning {{auto property synthesis is synthesizing property not explicitly synthesized}} |
152 | |
153 | @end |
154 | |
155 | @implementation DontWarnOnUnavailable // expected-note {{detected while default synthesizing properties in class implementation}} |
156 | |
157 | @end |
158 | |