Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify -Wno-objc-root-class %s |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 2 | |
| 3 | typedef unsigned long NSUInteger; |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 4 | typedef const void * CFTypeRef; |
| 5 | CFTypeRef CFBridgingRetain(id X); |
| 6 | id CFBridgingRelease(CFTypeRef); |
Ted Kremenek | 9d08401 | 2012-12-21 08:04:28 +0000 | [diff] [blame] | 7 | @protocol NSCopying @end |
| 8 | @interface NSDictionary |
| 9 | + (id)dictionaryWithObjects:(const id [])objects forKeys:(const id <NSCopying> [])keys count:(NSUInteger)cnt; |
| 10 | - (void)setObject:(id)object forKeyedSubscript:(id)key; |
| 11 | @end |
| 12 | @class NSFastEnumerationState; |
| 13 | @protocol NSFastEnumeration |
Douglas Gregor | f373c5d | 2013-01-18 01:41:40 +0000 | [diff] [blame] | 14 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id __unsafe_unretained [])buffer count:(NSUInteger)len; |
Ted Kremenek | 9d08401 | 2012-12-21 08:04:28 +0000 | [diff] [blame] | 15 | @end |
| 16 | @interface NSNumber |
| 17 | + (NSNumber *)numberWithInt:(int)value; |
| 18 | @end |
| 19 | @interface NSArray <NSFastEnumeration> |
| 20 | + (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; |
| 21 | @end |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 22 | |
| 23 | void test0(void (*fn)(int), int val) { |
| 24 | fn(val); |
| 25 | } |
| 26 | |
| 27 | @interface A |
| 28 | - (id)retain; |
| 29 | - (id)autorelease; |
| 30 | - (oneway void)release; |
| 31 | - (void)dealloc; |
| 32 | - (NSUInteger)retainCount; |
| 33 | @end |
| 34 | |
| 35 | void test1(A *a) { |
| 36 | SEL s = @selector(retain); // expected-error {{ARC forbids use of 'retain' in a @selector}} |
| 37 | s = @selector(release); // expected-error {{ARC forbids use of 'release' in a @selector}} |
| 38 | s = @selector(autorelease); // expected-error {{ARC forbids use of 'autorelease' in a @selector}} |
| 39 | s = @selector(dealloc); // expected-error {{ARC forbids use of 'dealloc' in a @selector}} |
| 40 | [a dealloc]; // expected-error {{ARC forbids explicit message send of 'dealloc'}} |
| 41 | [a retain]; // expected-error {{ARC forbids explicit message send of 'retain'}} |
| 42 | [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}} |
| 43 | [a release]; // expected-error {{ARC forbids explicit message send of 'release'}} |
| 44 | [a autorelease]; // expected-error {{ARC forbids explicit message send of 'autorelease'}} |
| 45 | } |
| 46 | |
| 47 | @interface Test2 : A |
| 48 | - (void) dealloc; |
| 49 | @end |
| 50 | @implementation Test2 |
| 51 | - (void) dealloc { |
| 52 | // This should maybe just be ignored. We're just going to warn about it for now. |
| 53 | [super dealloc]; // expected-error {{ARC forbids explicit message send of 'dealloc'}} |
| 54 | } |
| 55 | @end |
| 56 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 57 | // rdar://8843638 |
| 58 | |
| 59 | @interface I |
Ted Kremenek | 3306ec1 | 2012-02-27 22:55:11 +0000 | [diff] [blame] | 60 | - (id)retain; // expected-note {{method 'retain' declared here}} |
| 61 | - (id)autorelease; // expected-note {{method 'autorelease' declared here}} |
| 62 | - (oneway void)release; // expected-note {{method 'release' declared here}} |
| 63 | - (NSUInteger)retainCount; // expected-note {{method 'retainCount' declared here}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 64 | @end |
| 65 | |
| 66 | @implementation I |
| 67 | - (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}} |
| 68 | - (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}} |
| 69 | - (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}} |
| 70 | - (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}} |
| 71 | @end |
| 72 | |
| 73 | @implementation I(CAT) |
Fariborz Jahanian | fefe91e | 2011-07-28 23:19:50 +0000 | [diff] [blame] | 74 | - (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}} \ |
| 75 | // expected-warning {{category is implementing a method which will also be implemented by its primary class}} |
| 76 | - (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}} \ |
| 77 | // expected-warning {{category is implementing a method which will also be implemented by its primary class}} |
| 78 | - (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}} \ |
| 79 | // expected-warning {{category is implementing a method which will also be implemented by its primary class}} |
| 80 | - (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}} \ |
| 81 | // expected-warning {{category is implementing a method which will also be implemented by its primary class}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 82 | @end |
| 83 | |
| 84 | // rdar://8861761 |
| 85 | |
| 86 | @interface B |
| 87 | -(id)alloc; |
| 88 | - (id)initWithInt: (int) i; |
| 89 | @end |
| 90 | |
| 91 | void rdar8861761() { |
| 92 | B *o1 = [[B alloc] initWithInt:0]; |
| 93 | B *o2 = [B alloc]; |
| 94 | [o2 initWithInt:0]; // expected-warning {{expression result unused}} |
| 95 | } |
| 96 | |
| 97 | // rdar://8925835 |
| 98 | @interface rdar8925835 |
| 99 | - (void)foo:(void (^)(unsigned captureCount, I * const capturedStrings[captureCount]))block; |
| 100 | @end |
| 101 | |
| 102 | void test5() { |
| 103 | extern void test5_helper(__autoreleasing id *); |
| 104 | id x; |
| 105 | |
| 106 | // Okay because of magic temporaries. |
| 107 | test5_helper(&x); |
| 108 | |
| 109 | __autoreleasing id *a = &x; // expected-error {{initializing '__autoreleasing id *' with an expression of type '__strong id *' changes retain/release properties of pointer}} |
| 110 | |
| 111 | a = &x; // expected-error {{assigning '__strong id *' to '__autoreleasing id *' changes retain/release properties of pointer}} |
| 112 | |
| 113 | extern void test5_helper2(id const *); |
| 114 | test5_helper2(&x); |
| 115 | |
| 116 | extern void test5_helper3(__weak id *); // expected-note {{passing argument to parameter here}} |
| 117 | test5_helper3(&x); // expected-error {{passing '__strong id *' to parameter of type '__weak id *' changes retain/release properties of pointer}} |
| 118 | } |
| 119 | |
| 120 | // rdar://problem/8937869 |
| 121 | void test6(unsigned cond) { |
| 122 | switch (cond) { |
| 123 | case 0: |
| 124 | ; |
| 125 | id x; // expected-note {{jump bypasses initialization of retaining variable}} |
| 126 | |
| 127 | case 1: // expected-error {{switch case is in protected scope}} |
| 128 | break; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | @class NSError; |
| 133 | void test7(void) { |
| 134 | extern void test7_helper(NSError **); |
| 135 | NSError *err; |
| 136 | test7_helper(&err); |
| 137 | } |
| 138 | void test7_weak(void) { |
| 139 | extern void test7_helper(NSError **); |
| 140 | __weak NSError *err; |
| 141 | test7_helper(&err); |
| 142 | } |
| 143 | void test7_unsafe(void) { |
| 144 | extern void test7_helper(NSError **); // expected-note {{passing argument to parameter here}} |
| 145 | __unsafe_unretained NSError *err; |
| 146 | test7_helper(&err); // expected-error {{passing 'NSError *__unsafe_unretained *' to parameter of type 'NSError *__autoreleasing *' changes retain/release properties of pointer}} |
| 147 | } |
| 148 | |
| 149 | @class Test8_incomplete; |
| 150 | @interface Test8_complete @end; |
| 151 | @interface Test8_super @end; |
| 152 | @interface Test8 : Test8_super |
| 153 | - (id) init00; |
| 154 | - (id) init01; // expected-note {{declaration in interface}} \ |
| 155 | // expected-note{{overridden method}} |
| 156 | - (id) init02; // expected-note{{overridden method}} |
| 157 | - (id) init03; // covariance |
| 158 | - (id) init04; // covariance |
| 159 | - (id) init05; // expected-note{{overridden method}} |
| 160 | |
| 161 | - (void) init10; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} |
| 162 | - (void) init11; |
| 163 | - (void) init12; |
| 164 | - (void) init13; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} |
| 165 | - (void) init14; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}} |
| 166 | - (void) init15; |
| 167 | |
| 168 | // These should be invalid to actually call. |
| 169 | - (Test8_incomplete*) init20; |
| 170 | - (Test8_incomplete*) init21; // expected-note {{declaration in interface}} |
| 171 | - (Test8_incomplete*) init22; |
| 172 | - (Test8_incomplete*) init23; |
| 173 | - (Test8_incomplete*) init24; |
| 174 | - (Test8_incomplete*) init25; |
| 175 | |
| 176 | - (Test8_super*) init30; // id exception to covariance |
| 177 | - (Test8_super*) init31; // expected-note {{declaration in interface}} \ |
| 178 | // expected-note{{overridden method}} |
| 179 | - (Test8_super*) init32; // expected-note{{overridden method}} |
| 180 | - (Test8_super*) init33; |
| 181 | - (Test8_super*) init34; // covariance |
| 182 | - (Test8_super*) init35; // expected-note{{overridden method}} |
| 183 | |
| 184 | - (Test8*) init40; // id exception to covariance |
| 185 | - (Test8*) init41; // expected-note {{declaration in interface}} \ |
| 186 | // expected-note{{overridden method}} |
| 187 | - (Test8*) init42; // expected-note{{overridden method}} |
| 188 | - (Test8*) init43; // this should be a warning, but that's a general language thing, not an ARC thing |
| 189 | - (Test8*) init44; |
| 190 | - (Test8*) init45; // expected-note{{overridden method}} |
| 191 | |
| 192 | - (Test8_complete*) init50; // expected-error {{init methods must return a type related to the receiver type}} |
| 193 | - (Test8_complete*) init51; // expected-error {{init methods must return a type related to the receiver type}} |
| 194 | - (Test8_complete*) init52; // expected-error {{init methods must return a type related to the receiver type}} |
| 195 | - (Test8_complete*) init53; // expected-error {{init methods must return a type related to the receiver type}} |
| 196 | - (Test8_complete*) init54; // expected-error {{init methods must return a type related to the receiver type}} |
| 197 | - (Test8_complete*) init55; // expected-error {{init methods must return a type related to the receiver type}} |
| 198 | @end |
| 199 | @implementation Test8 |
| 200 | - (id) init00 { return 0; } |
| 201 | - (id) init10 { return 0; } // expected-error {{method implementation does not match its declaration}} |
| 202 | - (id) init20 { return 0; } |
| 203 | - (id) init30 { return 0; } |
| 204 | - (id) init40 { return 0; } |
| 205 | - (id) init50 { return 0; } |
| 206 | |
| 207 | - (void) init01 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} \ |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 208 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 209 | - (void) init11 {} |
| 210 | - (void) init21 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} |
| 211 | - (void) init31 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} \ |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 212 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 213 | - (void) init41 {} // expected-error {{method was declared as an 'init' method, but its implementation doesn't match because its result type is not an object pointer}} \ |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 214 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 215 | - (void) init51 {} |
| 216 | |
| 217 | - (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \ |
| 218 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}} |
| 219 | - (Test8_incomplete*) init12 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} |
| 220 | - (Test8_incomplete*) init22 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} |
| 221 | - (Test8_incomplete*) init32 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \ |
| 222 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}} |
| 223 | - (Test8_incomplete*) init42 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \ |
| 224 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}} |
| 225 | - (Test8_incomplete*) init52 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} |
| 226 | |
| 227 | - (Test8_super*) init03 { return 0; } |
| 228 | - (Test8_super*) init13 { return 0; } // expected-error {{method implementation does not match its declaration}} |
| 229 | - (Test8_super*) init23 { return 0; } |
| 230 | - (Test8_super*) init33 { return 0; } |
| 231 | - (Test8_super*) init43 { return 0; } |
| 232 | - (Test8_super*) init53 { return 0; } |
| 233 | |
| 234 | - (Test8*) init04 { return 0; } |
| 235 | - (Test8*) init14 { return 0; } // expected-error {{method implementation does not match its declaration}} |
| 236 | - (Test8*) init24 { return 0; } |
| 237 | - (Test8*) init34 { return 0; } |
| 238 | - (Test8*) init44 { return 0; } |
| 239 | - (Test8*) init54 { return 0; } |
| 240 | |
| 241 | - (Test8_complete*) init05 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \ |
| 242 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}} |
| 243 | - (Test8_complete*) init15 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} |
| 244 | - (Test8_complete*) init25 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} |
| 245 | - (Test8_complete*) init35 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \ |
| 246 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}} |
| 247 | - (Test8_complete*) init45 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \ |
| 248 | // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}} |
| 249 | - (Test8_complete*) init55 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} |
| 250 | @end |
| 251 | |
| 252 | @class Test9_incomplete; |
| 253 | @interface Test9 |
| 254 | - (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}} |
| 255 | - (Test9_incomplete*) init2; |
| 256 | @end |
| 257 | id test9(Test9 *v) { |
| 258 | return [v init1]; |
| 259 | } |
| 260 | |
| 261 | // Test that the inference rules are different for fast enumeration variables. |
| 262 | void test10(id collection) { |
| 263 | for (id x in collection) { |
John McCall | 7acddac | 2011-06-17 06:42:21 +0000 | [diff] [blame] | 264 | __strong id *ptr = &x; // expected-warning {{initializing '__strong id *' with an expression of type 'const __strong id *' discards qualifiers}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 265 | } |
| 266 | |
| 267 | for (__strong id x in collection) { |
| 268 | __weak id *ptr = &x; // expected-error {{initializing '__weak id *' with an expression of type '__strong id *' changes retain/release properties of pointer}} |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | // rdar://problem/9078626 |
| 273 | #define nil ((void*) 0) |
| 274 | void test11(id op, void *vp) { |
| 275 | _Bool b; |
| 276 | b = (op == nil); |
| 277 | b = (nil == op); |
| 278 | |
| 279 | b = (vp == nil); |
| 280 | b = (nil == vp); |
| 281 | |
Fariborz Jahanian | 607f587 | 2012-07-27 21:34:23 +0000 | [diff] [blame] | 282 | b = (vp == op); // expected-error {{implicit conversion of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRetain call}} |
| 283 | b = (op == vp); // expected-error {{implicit conversion of C pointer type 'void *' to Objective-C pointer type 'id' requires a bridged cast}} expected-note {{use __bridge}} expected-note {{use CFBridgingRelease call}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 284 | } |
| 285 | |
| 286 | void test12(id collection) { |
| 287 | for (id x in collection) { |
| 288 | x = 0; // expected-error {{fast enumeration variables can't be modified in ARC by default; declare the variable __strong to allow this}} |
| 289 | } |
| 290 | |
| 291 | for (const id x in collection) { |
| 292 | x = 0; // expected-error {{read-only variable is not assignable}} |
| 293 | } |
| 294 | |
| 295 | for (__strong id x in collection) { |
| 296 | x = 0; |
| 297 | } |
| 298 | } |
| 299 | |
| 300 | @interface Test13 |
| 301 | - (id) init0; |
| 302 | - (void) noninit; |
| 303 | @end |
| 304 | @implementation Test13 |
| 305 | - (id) init0 { |
| 306 | self = 0; |
| 307 | } |
| 308 | - (void) noninit { |
| 309 | self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}} |
| 310 | } |
| 311 | @end |
| 312 | |
Ted Kremenek | 3045ce7 | 2011-10-25 04:52:20 +0000 | [diff] [blame] | 313 | // <rdar://problem/10274056> |
| 314 | @interface Test13_B |
| 315 | - (id) consumesSelf __attribute__((ns_consumes_self)); |
| 316 | @end |
| 317 | @implementation Test13_B |
| 318 | - (id) consumesSelf { |
| 319 | self = 0; // no-warning |
| 320 | } |
| 321 | @end |
| 322 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 323 | // rdar://problem/9172151 |
| 324 | @class Test14A, Test14B; |
| 325 | void test14() { |
| 326 | extern void test14_consume(id *); |
| 327 | extern int test14_cond(void); |
| 328 | extern float test14_nowriteback(id __autoreleasing const *); // expected-note{{passing argument to parameter here}} |
| 329 | |
| 330 | Test14A *a; |
| 331 | Test14B *b; |
| 332 | id i; |
| 333 | id cla[10]; |
| 334 | id vla[test14_cond() + 10]; |
| 335 | |
| 336 | test14_consume((__strong id*) &a); |
| 337 | test14_consume((test14_cond() ? (__strong id*) &b : &i)); |
| 338 | test14_consume(test14_cond() ? 0 : &a); |
| 339 | test14_consume(test14_cond() ? (void*) 0 : (&a)); |
| 340 | test14_consume(cla); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}} |
| 341 | test14_consume(vla); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}} |
| 342 | test14_consume(&cla[5]); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}} |
| 343 | |
| 344 | __strong id *test14_indirect(void); |
| 345 | test14_consume(test14_indirect()); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}} |
| 346 | |
| 347 | extern id test14_global; |
| 348 | test14_consume(&test14_global); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}} |
| 349 | |
| 350 | extern __strong id *test14_global_ptr; |
| 351 | test14_consume(test14_global_ptr); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}} |
| 352 | |
| 353 | static id static_local; |
| 354 | test14_consume(&static_local); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}} |
| 355 | |
| 356 | __weak id* wip; |
| 357 | test14_nowriteback(&static_local); // okay, not a write-back. |
| 358 | test14_nowriteback(wip); // expected-error{{passing '__weak id *' to parameter of type '__autoreleasing id const *' changes retain/release properties of pointer}} |
| 359 | } |
| 360 | |
| 361 | void test15() { |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 362 | __block __autoreleasing id x; // expected-error {{__block variables cannot have __autoreleasing ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | struct Test16; |
| 366 | @interface Test16a |
| 367 | - (void) test16_0: (int) x; |
| 368 | - (int) test16_1: (int) x; // expected-note {{one possibility}} |
| 369 | - (int) test16_2: (int) x; // expected-note {{one possibility}} |
| 370 | - (id) test16_3: (int) x __attribute__((ns_returns_retained)); // expected-note {{one possibility}} |
| 371 | - (void) test16_4: (int) x __attribute__((ns_consumes_self)); // expected-note {{one possibility}} |
| 372 | - (void) test16_5: (id) __attribute__((ns_consumed)) x; // expected-note {{one possibility}} |
| 373 | - (void) test16_6: (id) x; |
| 374 | @end |
| 375 | |
| 376 | @interface Test16b |
| 377 | - (void) test16_0: (int) x; |
| 378 | - (int) test16_1: (char*) x; // expected-note {{also found}} |
| 379 | - (char*) test16_2: (int) x; // expected-note {{also found}} |
| 380 | - (id) test16_3: (int) x; // expected-note {{also found}} |
| 381 | - (void) test16_4: (int) x; // expected-note {{also found}} |
| 382 | - (void) test16_5: (id) x; // expected-note {{also found}} |
| 383 | - (void) test16_6: (struct Test16 *) x; |
| 384 | @end |
| 385 | |
| 386 | void test16(void) { |
| 387 | id v; |
| 388 | [v test16_0: 0]; |
| 389 | [v test16_1: 0]; // expected-error {{multiple methods named 'test16_1:' found with mismatched result, parameter type or attributes}} |
| 390 | [v test16_2: 0]; // expected-error {{multiple methods named}} |
| 391 | [v test16_3: 0]; // expected-error {{multiple methods named}} |
| 392 | [v test16_4: 0]; // expected-error {{multiple methods named}} |
| 393 | [v test16_5: 0]; // expected-error {{multiple methods named}} |
| 394 | [v test16_6: 0]; |
| 395 | } |
| 396 | |
Douglas Gregor | b302996 | 2011-11-14 22:10:01 +0000 | [diff] [blame] | 397 | @class Test17; // expected-note 2{{forward declaration of class here}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 398 | @protocol Test17p |
| 399 | - (void) test17; |
| 400 | + (void) test17; |
| 401 | @end |
| 402 | void test17(void) { |
| 403 | Test17 *v0; |
| 404 | [v0 test17]; // expected-error {{receiver type 'Test17' for instance message is a forward declaration}} |
| 405 | |
| 406 | Test17<Test17p> *v1; |
| 407 | [v1 test17]; // expected-error {{receiver type 'Test17<Test17p>' for instance message is a forward declaration}} |
| 408 | |
| 409 | [Test17 test17]; // expected-error {{receiver 'Test17' for class message is a forward declaration}} |
| 410 | } |
| 411 | |
| 412 | void test18(void) { |
| 413 | id x; |
| 414 | [x test18]; // expected-error {{no known instance method for selector 'test18'}} |
| 415 | } |
| 416 | |
| 417 | extern struct Test19 *test19a; |
| 418 | struct Test19 *const test19b = 0; |
| 419 | void test19(void) { |
| 420 | id x; |
| 421 | x = (id) test19a; // expected-error {{bridged cast}} \ |
Fariborz Jahanian | 607f587 | 2012-07-27 21:34:23 +0000 | [diff] [blame] | 422 | // expected-note{{use __bridge to convert directly (no change in ownership)}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 423 | // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 424 | x = (id) test19b; // expected-error {{bridged cast}} \ |
Fariborz Jahanian | 607f587 | 2012-07-27 21:34:23 +0000 | [diff] [blame] | 425 | // expected-note{{use __bridge to convert directly (no change in ownership)}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 426 | // expected-note{{use CFBridgingRelease call to transfer ownership of a +1 'struct Test19 *' into ARC}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 427 | } |
| 428 | |
| 429 | // rdar://problem/8951453 |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 430 | static __thread id test20_implicit; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}} |
| 431 | static __thread __strong id test20_strong; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}} |
| 432 | static __thread __weak id test20_weak; // expected-error {{thread-local variable has non-trivial ownership: type is '__weak id'}} |
| 433 | static __thread __autoreleasing id test20_autoreleasing; // expected-error {{thread-local variable has non-trivial ownership: type is '__autoreleasing id'}} expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 434 | static __thread __unsafe_unretained id test20_unsafe; |
| 435 | void test20(void) { |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 436 | static __thread id test20_implicit; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}} |
| 437 | static __thread __strong id test20_strong; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}} |
| 438 | static __thread __weak id test20_weak; // expected-error {{thread-local variable has non-trivial ownership: type is '__weak id'}} |
| 439 | static __thread __autoreleasing id test20_autoreleasing; // expected-error {{thread-local variable has non-trivial ownership: type is '__autoreleasing id'}} expected-error {{global variables cannot have __autoreleasing ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 440 | static __thread __unsafe_unretained id test20_unsafe; |
| 441 | } |
| 442 | |
| 443 | // rdar://9310049 |
| 444 | _Bool fn(id obj) { |
| 445 | return (_Bool)obj; |
| 446 | } |
| 447 | |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 448 | // Check casting w/ ownership qualifiers. |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 449 | void test21() { |
| 450 | __strong id *sip; |
| 451 | (void)(__weak id *)sip; // expected-error{{casting '__strong id *' to type '__weak id *' changes retain/release properties of pointer}} |
| 452 | (void)(__weak const id *)sip; // expected-error{{casting '__strong id *' to type '__weak id const *' changes retain/release properties of pointer}} |
| 453 | (void)(__autoreleasing id *)sip; // expected-error{{casting '__strong id *' to type '__autoreleasing id *' changes retain/release properties of pointer}} |
| 454 | (void)(__autoreleasing const id *)sip; // okay |
| 455 | } |
| 456 | |
| 457 | // rdar://problem/9340462 |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 458 | void test22(id x[]) { // expected-error {{must explicitly describe intended ownership of an object array parameter}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | // rdar://problem/9400219 |
| 462 | void test23(void) { |
| 463 | void *ptr; |
| 464 | ptr = @"foo"; |
| 465 | ptr = (ptr ? @"foo" : 0); |
| 466 | ptr = (ptr ? @"foo" : @"bar"); |
| 467 | } |
| 468 | |
| 469 | id test24(void) { |
| 470 | extern void test24_helper(void); |
| 471 | return test24_helper(), (void*) 0; |
| 472 | } |
| 473 | |
| 474 | // rdar://9400841 |
| 475 | @interface Base |
| 476 | @property (assign) id content; |
| 477 | @end |
| 478 | |
| 479 | @interface Foo : Base |
| 480 | -(void)test; |
| 481 | @end |
| 482 | |
| 483 | @implementation Foo |
| 484 | -(void)test { |
| 485 | super.content = 0; |
| 486 | } |
| 487 | @end |
| 488 | |
| 489 | // <rdar://problem/9398437> |
| 490 | void test25(Class *classes) { |
| 491 | Class *other_classes; |
| 492 | test25(other_classes); |
| 493 | } |
| 494 | |
| 495 | void test26(id y) { |
| 496 | extern id test26_var1; |
Argyrios Kyrtzidis | b8b0313 | 2011-06-24 00:08:59 +0000 | [diff] [blame] | 497 | __sync_swap(&test26_var1, 0, y); // expected-error {{cannot perform atomic operation on a pointer to type '__strong id': type has non-trivial ownership}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 498 | |
| 499 | extern __unsafe_unretained id test26_var2; |
| 500 | __sync_swap(&test26_var2, 0, y); |
| 501 | } |
| 502 | |
| 503 | @interface Test26 |
| 504 | - (id) init; |
| 505 | - (id) initWithInt: (int) x; |
| 506 | @end |
| 507 | @implementation Test26 |
| 508 | - (id) init { return self; } |
| 509 | - (id) initWithInt: (int) x { |
| 510 | [self init]; // expected-error {{the result of a delegate init call must be immediately returned or assigned to 'self'}} |
| 511 | return self; |
| 512 | } |
| 513 | @end |
| 514 | |
| 515 | // rdar://9525555 |
Argyrios Kyrtzidis | 473506b | 2011-07-26 21:48:26 +0000 | [diff] [blame] | 516 | @interface Test27 { |
| 517 | __weak id _myProp1; |
| 518 | id myProp2; |
| 519 | } |
Fariborz Jahanian | bc03aea | 2011-08-19 19:28:44 +0000 | [diff] [blame] | 520 | @property id x; |
Fariborz Jahanian | f21a92d | 2011-11-08 20:58:53 +0000 | [diff] [blame] | 521 | @property (readonly) id ro; |
Argyrios Kyrtzidis | 0a68dc7 | 2011-07-12 04:30:16 +0000 | [diff] [blame] | 522 | @property (readonly) id custom_ro; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 523 | @property int y; |
Argyrios Kyrtzidis | 473506b | 2011-07-26 21:48:26 +0000 | [diff] [blame] | 524 | |
Fariborz Jahanian | f21a92d | 2011-11-08 20:58:53 +0000 | [diff] [blame] | 525 | @property (readonly) __weak id myProp1; |
Argyrios Kyrtzidis | 473506b | 2011-07-26 21:48:26 +0000 | [diff] [blame] | 526 | @property (readonly) id myProp2; |
| 527 | @property (readonly) __strong id myProp3; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 528 | @end |
| 529 | |
Argyrios Kyrtzidis | 0a68dc7 | 2011-07-12 04:30:16 +0000 | [diff] [blame] | 530 | @implementation Test27 |
Fariborz Jahanian | bc03aea | 2011-08-19 19:28:44 +0000 | [diff] [blame] | 531 | @synthesize x; |
Fariborz Jahanian | f21a92d | 2011-11-08 20:58:53 +0000 | [diff] [blame] | 532 | @synthesize ro; |
Argyrios Kyrtzidis | 0a68dc7 | 2011-07-12 04:30:16 +0000 | [diff] [blame] | 533 | @synthesize y; |
Argyrios Kyrtzidis | 473506b | 2011-07-26 21:48:26 +0000 | [diff] [blame] | 534 | |
| 535 | @synthesize myProp1 = _myProp1; |
| 536 | @synthesize myProp2; |
| 537 | @synthesize myProp3; |
| 538 | |
Argyrios Kyrtzidis | 0a68dc7 | 2011-07-12 04:30:16 +0000 | [diff] [blame] | 539 | -(id)custom_ro { return 0; } |
| 540 | @end |
| 541 | |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 542 | // rdar://9569264 |
| 543 | @interface Test28 |
| 544 | @property (nonatomic, assign) __strong id a; // expected-error {{unsafe_unretained property 'a' may not also be declared __strong}} |
| 545 | @end |
| 546 | |
| 547 | @interface Test28 () |
| 548 | @property (nonatomic, assign) __strong id b; // expected-error {{unsafe_unretained property 'b' may not also be declared __strong}} |
| 549 | @end |
| 550 | |
| 551 | @implementation Test28 |
| 552 | @synthesize a; |
| 553 | @synthesize b; |
| 554 | @end |
| 555 | |
| 556 | // rdar://9573962 |
| 557 | typedef struct Bark Bark; |
| 558 | @interface Test29 |
| 559 | @property Bark* P; |
| 560 | @end |
| 561 | |
| 562 | @implementation Test29 |
| 563 | @synthesize P; |
| 564 | - (id)Meth { |
| 565 | Bark** f = &P; |
| 566 | return 0; |
| 567 | } |
| 568 | @end |
| 569 | |
| 570 | // rdar://9495837 |
| 571 | @interface Test30 |
Fariborz Jahanian | 921c143 | 2011-06-24 18:25:34 +0000 | [diff] [blame] | 572 | + (id) new; |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 573 | - (void)Meth; |
| 574 | @end |
| 575 | |
| 576 | @implementation Test30 |
Fariborz Jahanian | 921c143 | 2011-06-24 18:25:34 +0000 | [diff] [blame] | 577 | + (id) new { return 0; } |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 578 | - (void) Meth { |
Argyrios Kyrtzidis | d26fef0 | 2011-06-22 18:03:53 +0000 | [diff] [blame] | 579 | __weak id x = [Test30 new]; // expected-warning {{assigning retained object to weak variable}} |
| 580 | id __unsafe_unretained u = [Test30 new]; // expected-warning {{assigning retained object to unsafe_unretained variable}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 581 | id y = [Test30 new]; |
Argyrios Kyrtzidis | d26fef0 | 2011-06-22 18:03:53 +0000 | [diff] [blame] | 582 | x = [Test30 new]; // expected-warning {{assigning retained object to weak variable}} |
| 583 | u = [Test30 new]; // expected-warning {{assigning retained object to unsafe_unretained variable}} |
John McCall | f85e193 | 2011-06-15 23:02:42 +0000 | [diff] [blame] | 584 | y = [Test30 new]; |
| 585 | } |
| 586 | @end |
| 587 | |
| 588 | // rdar://9411838 |
| 589 | @protocol PTest31 @end |
| 590 | |
| 591 | int Test31() { |
| 592 | Class cls; |
| 593 | id ids; |
| 594 | id<PTest31> pids; |
| 595 | Class<PTest31> pcls; |
| 596 | |
| 597 | int i = (ids->isa ? 1 : 0); // expected-error {{member reference base type 'id' is not a structure or union}} |
| 598 | int j = (pids->isa ? 1 : 0); // expected-error {{member reference base type 'id<PTest31>' is not a structure or union}} |
| 599 | int k = (pcls->isa ? i : j); // expected-error {{member reference base type 'Class<PTest31>' is not a structure or union}} |
| 600 | return cls->isa ? i : j; // expected-error {{member reference base type 'Class' is not a structure or union}} |
| 601 | } |
Fariborz Jahanian | b1f7d24 | 2011-06-16 17:29:56 +0000 | [diff] [blame] | 602 | |
| 603 | // rdar://9612030 |
| 604 | @interface ITest32 { |
| 605 | @public |
| 606 | id ivar; |
| 607 | } |
| 608 | @end |
| 609 | |
| 610 | id Test32(__weak ITest32 *x) { |
| 611 | __weak ITest32 *y; |
| 612 | x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}} |
| 613 | return y ? y->ivar // expected-error {{dereferencing a __weak pointer is not allowed}} |
| 614 | : (*x).ivar; // expected-error {{dereferencing a __weak pointer is not allowed}} |
| 615 | } |
| 616 | |
Fariborz Jahanian | 8295b7b | 2011-06-22 16:36:45 +0000 | [diff] [blame] | 617 | // rdar://9619861 |
| 618 | extern int printf(const char*, ...); |
| 619 | typedef long intptr_t; |
| 620 | |
| 621 | int Test33(id someid) { |
| 622 | printf( "Hello%ld", (intptr_t)someid); |
| 623 | return (int)someid; |
| 624 | } |
| 625 | |
Fariborz Jahanian | 831fb96 | 2011-06-25 00:17:46 +0000 | [diff] [blame] | 626 | // rdar://9636091 |
| 627 | @interface I34 |
| 628 | @property (nonatomic, retain) id newName __attribute__((ns_returns_not_retained)) ; |
| 629 | |
| 630 | @property (nonatomic, retain) id newName1 __attribute__((ns_returns_not_retained)) ; |
| 631 | - (id) newName1 __attribute__((ns_returns_not_retained)); |
| 632 | |
| 633 | @property (nonatomic, retain) id newName2 __attribute__((ns_returns_not_retained)); // expected-note {{roperty declared here}} |
| 634 | - (id) newName2; // expected-warning {{property declared as returning non-retained objects; getter returning retained objects}} |
| 635 | @end |
| 636 | |
| 637 | @implementation I34 |
| 638 | @synthesize newName; |
| 639 | |
| 640 | @synthesize newName1; |
Fariborz Jahanian | 7898005 | 2011-08-01 22:39:49 +0000 | [diff] [blame] | 641 | - (id) newName1 { return 0; } |
Fariborz Jahanian | 831fb96 | 2011-06-25 00:17:46 +0000 | [diff] [blame] | 642 | |
Fariborz Jahanian | 7898005 | 2011-08-01 22:39:49 +0000 | [diff] [blame] | 643 | @synthesize newName2; |
Fariborz Jahanian | 831fb96 | 2011-06-25 00:17:46 +0000 | [diff] [blame] | 644 | @end |
| 645 | |
John McCall | c03fa49 | 2011-06-27 23:59:58 +0000 | [diff] [blame] | 646 | void test35(void) { |
| 647 | extern void test36_helper(id*); |
| 648 | id x; |
| 649 | __strong id *xp = 0; |
| 650 | |
| 651 | test36_helper(&x); |
| 652 | test36_helper(xp); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}} |
| 653 | |
| 654 | // rdar://problem/9665710 |
| 655 | __block id y; |
| 656 | test36_helper(&y); |
| 657 | ^{ test36_helper(&y); }(); |
Argyrios Kyrtzidis | 05d4876 | 2011-07-01 22:23:09 +0000 | [diff] [blame] | 658 | |
Jordan Rose | b13291a | 2012-07-19 18:10:18 +0000 | [diff] [blame] | 659 | __strong int non_objc_type; // expected-warning {{'__strong' only applies to Objective-C object or block pointer types}} |
John McCall | c03fa49 | 2011-06-27 23:59:58 +0000 | [diff] [blame] | 660 | } |
Douglas Gregor | f96e904 | 2011-07-12 17:28:52 +0000 | [diff] [blame] | 661 | |
| 662 | void test36(int first, ...) { |
| 663 | // <rdar://problem/9758798> |
| 664 | __builtin_va_list arglist; |
| 665 | __builtin_va_start(arglist, first); |
| 666 | id obj = __builtin_va_arg(arglist, id); |
| 667 | __builtin_va_end(arglist); |
| 668 | } |
John McCall | 990567c | 2011-07-27 01:07:15 +0000 | [diff] [blame] | 669 | |
Douglas Gregor | b302996 | 2011-11-14 22:10:01 +0000 | [diff] [blame] | 670 | @class Test37; // expected-note{{forward declaration of class here}} |
John McCall | 990567c | 2011-07-27 01:07:15 +0000 | [diff] [blame] | 671 | void test37(Test37 *c) { |
| 672 | for (id y in c) { // expected-error {{collection expression type 'Test37' is a forward declaration}} |
| 673 | (void) y; |
| 674 | } |
Argyrios Kyrtzidis | 5b76f37 | 2011-09-20 23:49:22 +0000 | [diff] [blame] | 675 | |
| 676 | (void)sizeof(id*); // no error. |
John McCall | 990567c | 2011-07-27 01:07:15 +0000 | [diff] [blame] | 677 | } |
John McCall | a8e0cd8 | 2011-08-06 07:30:58 +0000 | [diff] [blame] | 678 | |
| 679 | // rdar://problem/9887979 |
| 680 | @interface Test38 |
| 681 | @property int value; |
| 682 | @end |
| 683 | void test38() { |
| 684 | extern Test38 *test38_helper(void); |
| 685 | switch (test38_helper().value) { |
| 686 | case 0: |
| 687 | case 1: |
| 688 | ; |
| 689 | } |
| 690 | } |
Fariborz Jahanian | 175fb10 | 2011-10-03 22:11:57 +0000 | [diff] [blame] | 691 | |
| 692 | // rdar://10186536 |
| 693 | @class NSColor; |
| 694 | void _NSCalc(NSColor* color, NSColor* bezelColors[]) __attribute__((unavailable("not available in automatic reference counting mode"))); |
| 695 | |
| 696 | void _NSCalcBeze(NSColor* color, NSColor* bezelColors[]); // expected-error {{must explicitly describe intended ownership of an object array parameter}} |
Fariborz Jahanian | a1de8cb | 2011-10-14 17:34:08 +0000 | [diff] [blame] | 697 | |
| 698 | // rdar://9970739 |
| 699 | @interface RestaurantTableViewCell |
| 700 | - (void) restaurantLocation; |
| 701 | @end |
| 702 | |
| 703 | @interface Radar9970739 |
| 704 | - (void) Meth; |
| 705 | @end |
| 706 | |
| 707 | @implementation Radar9970739 |
| 708 | - (void) Meth { |
| 709 | RestaurantTableViewCell *cell; |
| 710 | [cell restaurantLocatoin]; // expected-error {{no visible @interface for 'RestaurantTableViewCell' declares the selector 'restaurantLocatoin'}} |
| 711 | } |
| 712 | @end |
| 713 | |
Fariborz Jahanian | bd2e27e | 2012-07-06 21:09:27 +0000 | [diff] [blame] | 714 | // rdar://11814185 |
| 715 | @interface Radar11814185 |
| 716 | @property (nonatomic, weak) Radar11814185* picker1; |
| 717 | + alloc; |
| 718 | - init; |
| 719 | @end |
| 720 | |
| 721 | @implementation Radar11814185 |
| 722 | |
| 723 | @synthesize picker1; |
| 724 | |
| 725 | - (void)viewDidLoad |
| 726 | { |
| 727 | picker1 = [[Radar11814185 alloc] init]; // expected-warning {{assigning retained object to weak variable; object will be released after assignment}} |
| 728 | self.picker1 = [[Radar11814185 alloc] init]; // expected-warning {{assigning retained object to weak property; object will be released after assignment}} |
| 729 | } |
| 730 | |
| 731 | + alloc { return 0; } |
| 732 | - init { return 0; } |
| 733 | @end |
| 734 | |
Ted Kremenek | 9d08401 | 2012-12-21 08:04:28 +0000 | [diff] [blame] | 735 | // <rdar://problem/12569201>. Warn on cases of initializing a weak variable |
| 736 | // with an Objective-C object literal. |
| 737 | void rdar12569201(id key, id value) { |
| 738 | // Declarations. |
| 739 | __weak id x = @"foo"; // no-warning |
| 740 | __weak id y = @{ key : value }; // expected-warning {{assigning dictionary literal to a weak variable; object will be released after assignment}} |
| 741 | __weak id z = @[ value ]; // expected-warning {{assigning array literal to a weak variable; object will be released after assignment}} |
| 742 | __weak id b = ^() {}; // expected-warning {{assigning block literal to a weak variable; object will be released after assignment}} |
Ted Kremenek | f530ff7 | 2012-12-21 21:59:39 +0000 | [diff] [blame] | 743 | __weak id n = @42; // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} |
| 744 | __weak id e = @(42); // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} |
| 745 | __weak id m = @(41 + 1); // expected-warning {{assigning boxed expression to a weak variable; object will be released after assignment}} |
Ted Kremenek | 9d08401 | 2012-12-21 08:04:28 +0000 | [diff] [blame] | 746 | |
| 747 | // Assignments. |
| 748 | y = @{ key : value }; // expected-warning {{assigning dictionary literal to a weak variable; object will be released after assignment}} |
| 749 | z = @[ value ]; // expected-warning {{assigning array literal to a weak variable; object will be released after assignment}} |
| 750 | b = ^() {}; // expected-warning {{assigning block literal to a weak variable; object will be released after assignment}} |
Ted Kremenek | f530ff7 | 2012-12-21 21:59:39 +0000 | [diff] [blame] | 751 | n = @42; // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} |
| 752 | e = @(42); // expected-warning {{assigning numeric literal to a weak variable; object will be released after assignment}} |
| 753 | m = @(41 + 1); // expected-warning {{assigning boxed expression to a weak variable; object will be released after assignment}} |
Ted Kremenek | 9d08401 | 2012-12-21 08:04:28 +0000 | [diff] [blame] | 754 | } |
Douglas Gregor | f373c5d | 2013-01-18 01:41:40 +0000 | [diff] [blame] | 755 | |
| 756 | @interface C |
| 757 | - (void)method:(id[])objects; // expected-error{{must explicitly describe intended ownership of an object array parameter}} |
| 758 | @end |