Debian Codegraph @

clang/test/SemaObjC/default-synthesize.m

raw
1 // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
2
3 @interface NSString @end
4
5 @interface NSObject @end
6
7 @interface SynthItAll
8 @property int howMany;
9 @property (retain) NSString* what;
10 @end
11
12 @implementation SynthItAll
13 #if !__has_feature(objc_default_synthesize_properties)
14 @synthesize howMany, what;
15 #endif
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 #if !__has_feature(objc_default_synthesize_properties)
26 @synthesize howMany, what;
27 #endif
28
29 - (int) howMany {
30 return self.howMany;
31 }
32 // - (void) setHowMany: (int) value
33
34 - (NSString*) what {
35 return self.what;
36 }
37 // - (void) setWhat: (NSString*) value
38 @end
39
40
41 @interface SynthGetter : NSObject
42 @property (nonatomic) int howMany; // REM: nonatomic to avoid warnings about only implementing one of the pair
43 @property (nonatomic, retain) NSString* what;
44 @end
45
46 @implementation SynthGetter
47 #if !__has_feature(objc_default_synthesize_properties)
48 @synthesize howMany, what;
49 #endif
50
51 // - (int) howMany
52 - (void) setHowMany: (int) value {
53 self.howMany = value;
54 }
55
56 // - (NSString*) what
57 - (void) setWhat: (NSString*) value {
58 if (self.what != value) {
59 }
60 }
61 @end
62
63
64 @interface SynthNone : NSObject
65 @property int howMany;
66 @property (retain) NSString* what;
67 @end
68
69 @implementation SynthNone
70 #if !__has_feature(objc_default_synthesize_properties)
71 @synthesize howMany, what; // REM: Redundant anyway
72 #endif
73
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 @end
89
90 @protocol TopProtocol
91 @property (readonly) id myString;
92 @end
93
94 @interface TopClass <TopProtocol>
95 {
96 id myString;
97 }
98 @end
99
100 @interface SubClass : TopClass <TopProtocol>
101 @end
102
103 @implementation SubClass @end
104
105 @interface C @end
106 @interface C (Category)
107 @property int p; // expected-note 2 {{property declared here}}
108 @end
109 @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 @end
112
113 // Don't complain if a property is already @synthesized by usr.
114 @interface D
115 {
116 }
117 @property int PROP;
118 @end
119
120 @implementation D
121 - (int) Meth { return self.PROP; }
122 #if __has_feature(objc_default_synthesize_properties)
123 @synthesize PROP=IVAR;
124 #endif
125 @end
126
127 @protocol MyProtocol
128 @property (nonatomic, strong) NSString *requiredString; // expected-note {{property declared here}}
129
130 @optional
131 @property (nonatomic, strong) NSString *optionalString;
132 @end
133
134 @interface MyClass <MyProtocol>
135 @end
136
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 @end
141 @protocol TMSourceManagerDelegate<NSObject>
142 @end
143
144 @protocol TMSourceManager <NSObject>
145 @property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;
146 @end
147
148 @interface TMSourceManager
149 @property (nonatomic, assign) id <TMSourceManagerDelegate> delegate;
150 @end
151
152 @protocol TMTimeZoneManager <TMSourceManager>
153 @end
154
155 @interface TimeZoneManager : TMSourceManager <TMTimeZoneManager>
156 @end
157
158 @implementation TimeZoneManager
159 @end
160
161 @protocol BaseProt
162 @property (assign) id prot;
163 @end
164
165 @interface Base<BaseProt>
166 @end
167
168 @interface I : Base<BaseProt>
169 @end
170
171 @implementation I
172 @end