[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaObjC / default-synthesize-3.m
blob9a05408aa06067be9b78bebd9e409933dd950f96
1 // RUN: %clang_cc1 -x objective-c -fsyntax-only -verify -Wno-objc-root-class %s
2 // RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify -Wno-objc-root-class %s
4 #if __has_attribute(objc_requires_property_definitions)
5 __attribute ((objc_requires_property_definitions)) 
6 #endif
7 @interface NoAuto // expected-note 2 {{class with specified objc_requires_property_definitions attribute is declared here}}
8 @property int NoAutoProp; // expected-note 2 {{property declared here}}
9 @end
11 @implementation NoAuto  // expected-warning {{property 'NoAutoProp' requires method 'NoAutoProp' to be defined}} \
12                         // expected-warning {{property 'NoAutoProp' requires method 'setNoAutoProp:'}}
13 @end
15 __attribute ((objc_requires_property_definitions))  // redundant, just for testing
16 @interface Sub : NoAuto  // expected-note 3 {{class with specified objc_requires_property_definitions attribute is declared here}}
17 @property (copy) id SubProperty; // expected-note 2 {{property declared here}}
18 @end
20 @implementation Sub // expected-warning {{property 'SubProperty' requires method 'SubProperty' to be defined}} \
21                     // expected-warning {{property 'SubProperty' requires method 'setSubProperty:' to be defined}}
22 @end
24 @interface Deep : Sub
25 @property (copy) id DeepProperty;
26 @property (copy) id DeepSynthProperty;
27 @property (copy) id DeepMustSynthProperty; // expected-note {{property declared here}}
28 @end
30 @implementation Deep // expected-warning {{property 'DeepMustSynthProperty' requires method 'setDeepMustSynthProperty:' to be defined}}
31 @dynamic DeepProperty;
32 @synthesize DeepSynthProperty;
33 - (id) DeepMustSynthProperty { return 0; }
34 @end
36 __attribute ((objc_requires_property_definitions)) // expected-error {{'objc_requires_property_definitions' attribute only applies to Objective-C interfaces}}
37 @interface Deep(CAT)
38 @end
40 __attribute ((objc_requires_property_definitions)) // expected-error {{'objc_requires_property_definitions' attribute only applies to Objective-C interfaces}}
41 @protocol P @end
43 // rdar://13388503
44 @interface NSObject @end
45 @protocol Foo
46 @property (readonly) char isFoo; // expected-note {{property declared here}}
47 @property (readonly) char isNotFree;  // expected-note {{property declared here}}
48 @end
50 @interface Bar : NSObject <Foo>
51 @end
53 @implementation Bar
54 - (char)isFoo {
55     return 0;
57 - (char)isNotFree {
58     return 0;
60 @end
62 @interface Baz : Bar
63 @end
65 @interface Baz ()
66 @property (readwrite) char isFoo; // expected-warning {{auto property synthesis will not synthesize property 'isFoo' because it is 'readwrite' but it will be synthesized 'readonly' via another property}}
67 @property char Property1; // expected-warning {{auto property synthesis will not synthesize property 'Property1' because it cannot share an ivar with another synthesized property}}
68 @property char Property2;
69 @property (readwrite) char isNotFree; // expected-warning {{auto property synthesis will not synthesize property 'isNotFree'}}
70 @end
72 @implementation Baz { // expected-note {{detected while default synthesizing properties in class implementation}}
73     char _isFoo;
74     char _isNotFree;
76 @synthesize Property2 = Property1; // expected-note {{property synthesized here}}
78 - (void) setIsNotFree : (char)Arg {
79   _isNotFree = Arg;
82 @end
84 // More test where such warnings should not be issued.
85 @protocol MyProtocol
86 -(void)setProp1:(id)x;
87 @end
89 @protocol P1 <MyProtocol>
90 @end
92 @interface B
93 @property (readonly) id prop;  // expected-note {{property declared here}}
94 @property (readonly) id prop1;  // expected-note {{property declared here}}
95 @property (readonly) id prop2;  // expected-note {{property declared here}}
96 @end
98 @interface B()
99 -(void)setProp:(id)x;
100 @end
102 @interface B(cat)
103 @property (readwrite) id prop2;
104 @end
106 @interface S : B<P1>
107 @property (assign,readwrite) id prop; // expected-warning {{auto property synthesis will not synthesize property 'prop'}}
108 @property (assign,readwrite) id prop1; // expected-warning {{auto property synthesis will not synthesize property 'prop1'}}
109 @property (assign,readwrite) id prop2; // expected-warning {{auto property synthesis will not synthesize property 'prop2'}}
110 @end
112 @implementation S // expected-note 3 {{detected while default synthesizing properties in class implementation}}
113 @end
115 // rdar://14085456
116 // No warning must be issued in this test.
117 @interface ParentObject
118 @end
120 @protocol TestObject 
121 @property (readonly) int six;
122 @end
124 @interface TestObject : ParentObject <TestObject>
125 @property int six;
126 @end
128 @implementation TestObject
129 @synthesize six;
130 @end
132 // rdar://14094682
133 // no warning in this test
134 @interface ISAChallenge : NSObject {
137 @property (assign, readonly) int failureCount;
138 @end
140 @interface ISSAChallenge : ISAChallenge {
141     int _failureCount;
143 @property (assign, readwrite) int failureCount;
144 @end
146 @implementation ISAChallenge
147 - (int)failureCount {
148     return 0;
150 @end
152 @implementation ISSAChallenge
154 @synthesize failureCount = _failureCount;
155 @end
157 __attribute ((objc_requires_property_definitions(1))) // expected-error {{'objc_requires_property_definitions' attribute takes no arguments}}
158 @interface I1
159 @end
161 // rdar://15051465
162 @protocol SubFooling
163   @property(nonatomic, readonly) id hoho; // expected-note 2 {{property declared here}}
164 @end
166 @protocol Fooing<SubFooling>
167   @property(nonatomic, readonly) id muahahaha; // expected-note 2 {{property declared here}}
168 @end
170 typedef NSObject<Fooing> FooObject;
172 @interface Okay : NSObject<Fooing>
173 @end
175 @implementation Okay // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}}
176 @end // expected-note 2 {{add a '@synthesize' directive}}
178 @interface Fail : FooObject
179 @end
181 @implementation Fail // expected-warning {{auto property synthesis will not synthesize property 'muahahaha' declared in protocol 'Fooing'}} expected-warning {{auto property synthesis will not synthesize property 'hoho' declared in protocol 'SubFooling'}}
182 @end // expected-note 2 {{add a '@synthesize' directive}}
184 // rdar://16089191
185 @class NSURL;
187 @interface Root
188 - (void)setFileURL : (NSURL *) arg;
189 - (void)setFile : (NSURL *) arg;
190 - (NSURL *)fileSys;
191 - (void)setFileSys : (NSURL *) arg;
192 - (NSURL *)fileKerl;
193 @end
195 @interface SuperClass : Root
196 - (NSURL *)fileURL;
197 - (NSURL *)file;
198 - (NSURL *)fileLog;
199 - (void)setFileLog : (NSURL *) arg;
200 - (void)setFileKerl : (NSURL *) arg;
201 @end
203 @protocol r16089191Protocol
204 @property (readonly) NSURL *fileURL;
205 @property (copy) NSURL *file;
206 @property (copy) NSURL *fileSys;
207 @property (copy) NSURL *fileLog;
208 @property (copy) NSURL *fileKerl;
209 @end
211 @interface SubClass : SuperClass <r16089191Protocol>
212 @end
214 @implementation SubClass
215 @end