• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-nonfragile-abi -fobjc-runtime-has-weak -fsyntax-only -fobjc-arc -fblocks -verify %s
2
3typedef unsigned long NSUInteger;
4
5void test0(void (*fn)(int), int val) {
6  fn(val);
7}
8
9@interface A
10- (id)retain;
11- (id)autorelease;
12- (oneway void)release;
13- (void)dealloc;
14- (NSUInteger)retainCount;
15@end
16
17void test1(A *a) {
18  SEL s = @selector(retain);	// expected-error {{ARC forbids use of 'retain' in a @selector}}
19  s = @selector(release);	// expected-error {{ARC forbids use of 'release' in a @selector}}
20  s = @selector(autorelease);	// expected-error {{ARC forbids use of 'autorelease' in a @selector}}
21  s = @selector(dealloc);	// expected-error {{ARC forbids use of 'dealloc' in a @selector}}
22  [a dealloc]; // expected-error {{ARC forbids explicit message send of 'dealloc'}}
23  [a retain]; // expected-error {{ARC forbids explicit message send of 'retain'}}
24  [a retainCount]; // expected-error {{ARC forbids explicit message send of 'retainCount'}}
25  [a release]; // expected-error {{ARC forbids explicit message send of 'release'}}
26  [a autorelease]; // expected-error {{ARC forbids explicit message send of 'autorelease'}}
27}
28
29@interface Test2 : A
30- (void) dealloc;
31@end
32@implementation Test2
33- (void) dealloc {
34  // This should maybe just be ignored.  We're just going to warn about it for now.
35  [super dealloc]; // expected-error {{ARC forbids explicit message send of 'dealloc'}}
36}
37@end
38
39__weak __strong id x; // expected-error {{the type '__strong id' already has retainment attributes}}
40
41// rdar://8843638
42
43@interface I
44- (id)retain;
45- (id)autorelease;
46- (oneway void)release;
47- (NSUInteger)retainCount;
48@end
49
50@implementation I
51- (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}}
52- (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}}
53- (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}}
54- (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}}
55@end
56
57@implementation I(CAT)
58- (id)retain{return 0;} // expected-error {{ARC forbids implementation of 'retain'}}
59- (id)autorelease{return 0;} // expected-error {{ARC forbids implementation of 'autorelease'}}
60- (oneway void)release{} // expected-error {{ARC forbids implementation of 'release'}}
61- (NSUInteger)retainCount{ return 0; } // expected-error {{ARC forbids implementation of 'retainCount'}}
62@end
63
64// rdar://8861761
65
66@interface B
67-(id)alloc;
68- (id)initWithInt: (int) i;
69@end
70
71void rdar8861761() {
72  B *o1 = [[B alloc] initWithInt:0];
73  B *o2 = [B alloc];
74  [o2 initWithInt:0]; // expected-warning {{expression result unused}}
75}
76
77// rdar://8925835
78@interface rdar8925835
79- (void)foo:(void (^)(unsigned captureCount, I * const capturedStrings[captureCount]))block;
80@end
81
82void test5() {
83  extern void test5_helper(__autoreleasing id *);
84  id x;
85
86  // Okay because of magic temporaries.
87  test5_helper(&x);
88
89  __autoreleasing id *a = &x; // expected-error {{initializing '__autoreleasing id *' with an expression of type '__strong id *' changes retain/release properties of pointer}}
90
91  a = &x; // expected-error {{assigning '__strong id *' to '__autoreleasing id *' changes retain/release properties of pointer}}
92
93  extern void test5_helper2(id const *);
94  test5_helper2(&x);
95
96  extern void test5_helper3(__weak id *); // expected-note {{passing argument to parameter here}}
97  test5_helper3(&x); // expected-error {{passing '__strong id *' to parameter of type '__weak id *' changes retain/release properties of pointer}}
98}
99
100// rdar://problem/8937869
101void test6(unsigned cond) {
102  switch (cond) {
103  case 0:
104    ;
105    id x; // expected-note {{jump bypasses initialization of retaining variable}}
106
107  case 1: // expected-error {{switch case is in protected scope}}
108    break;
109  }
110}
111
112@class NSError;
113void test7(void) {
114  extern void test7_helper(NSError **);
115  NSError *err;
116  test7_helper(&err);
117}
118void test7_weak(void) {
119  extern void test7_helper(NSError **);
120  __weak NSError *err;
121  test7_helper(&err);
122}
123void test7_unsafe(void) {
124  extern void test7_helper(NSError **); // expected-note {{passing argument to parameter here}}
125  __unsafe_unretained NSError *err;
126  test7_helper(&err); // expected-error {{passing 'NSError *__unsafe_unretained *' to parameter of type 'NSError *__autoreleasing *' changes retain/release properties of pointer}}
127}
128
129@class Test8_incomplete;
130@interface Test8_complete @end;
131@interface Test8_super @end;
132@interface Test8 : Test8_super
133- (id) init00;
134- (id) init01; // expected-note {{declaration in interface}} \
135               // expected-note{{overridden method}}
136- (id) init02; // expected-note{{overridden method}}
137- (id) init03; // covariance
138- (id) init04; // covariance
139- (id) init05; // expected-note{{overridden method}}
140
141- (void) init10; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}}
142- (void) init11;
143- (void) init12;
144- (void) init13; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}}
145- (void) init14; // expected-note {{declaration in interface is not in the 'init' family because its result type is not an object pointer}}
146- (void) init15;
147
148// These should be invalid to actually call.
149- (Test8_incomplete*) init20;
150- (Test8_incomplete*) init21; // expected-note {{declaration in interface}}
151- (Test8_incomplete*) init22;
152- (Test8_incomplete*) init23;
153- (Test8_incomplete*) init24;
154- (Test8_incomplete*) init25;
155
156- (Test8_super*) init30; // id exception to covariance
157- (Test8_super*) init31; // expected-note {{declaration in interface}} \
158                         // expected-note{{overridden method}}
159- (Test8_super*) init32; // expected-note{{overridden method}}
160- (Test8_super*) init33;
161- (Test8_super*) init34; // covariance
162- (Test8_super*) init35; // expected-note{{overridden method}}
163
164- (Test8*) init40; // id exception to covariance
165- (Test8*) init41; // expected-note {{declaration in interface}} \
166                   // expected-note{{overridden method}}
167- (Test8*) init42; // expected-note{{overridden method}}
168- (Test8*) init43; // this should be a warning, but that's a general language thing, not an ARC thing
169- (Test8*) init44;
170- (Test8*) init45; // expected-note{{overridden method}}
171
172- (Test8_complete*) init50; // expected-error {{init methods must return a type related to the receiver type}}
173- (Test8_complete*) init51; // expected-error {{init methods must return a type related to the receiver type}}
174- (Test8_complete*) init52; // expected-error {{init methods must return a type related to the receiver type}}
175- (Test8_complete*) init53; // expected-error {{init methods must return a type related to the receiver type}}
176- (Test8_complete*) init54; // expected-error {{init methods must return a type related to the receiver type}}
177- (Test8_complete*) init55; // expected-error {{init methods must return a type related to the receiver type}}
178@end
179@implementation Test8
180- (id) init00 { return 0; }
181- (id) init10 { return 0; } // expected-error {{method implementation does not match its declaration}}
182- (id) init20 { return 0; }
183- (id) init30 { return 0; }
184- (id) init40 { return 0; }
185- (id) init50 { return 0; }
186
187- (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}} \
188                   // expected-warning{{ method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
189- (void) init11 {}
190- (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}}
191- (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}} \
192                   // expected-warning{{ method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
193- (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}} \
194                   // expected-warning{{ method is expected to return an instance of its class type 'Test8', but is declared to return 'void'}}
195- (void) init51 {}
196
197- (Test8_incomplete*) init02 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
198                                           // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}}
199- (Test8_incomplete*) init12 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
200- (Test8_incomplete*) init22 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
201- (Test8_incomplete*) init32 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
202                                           // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}}
203- (Test8_incomplete*) init42 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
204                                           // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_incomplete *'}}
205- (Test8_incomplete*) init52 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
206
207- (Test8_super*) init03 { return 0; }
208- (Test8_super*) init13 { return 0; } // expected-error {{method implementation does not match its declaration}}
209- (Test8_super*) init23 { return 0; }
210- (Test8_super*) init33 { return 0; }
211- (Test8_super*) init43 { return 0; }
212- (Test8_super*) init53 { return 0; }
213
214- (Test8*) init04 { return 0; }
215- (Test8*) init14 { return 0; } // expected-error {{method implementation does not match its declaration}}
216- (Test8*) init24 { return 0; }
217- (Test8*) init34 { return 0; }
218- (Test8*) init44 { return 0; }
219- (Test8*) init54 { return 0; }
220
221- (Test8_complete*) init05 { 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_complete *'}}
223- (Test8_complete*) init15 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
224- (Test8_complete*) init25 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
225- (Test8_complete*) init35 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
226                                         // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}}
227- (Test8_complete*) init45 { return 0; } // expected-error {{init methods must return a type related to the receiver type}} \
228                                         // expected-warning{{method is expected to return an instance of its class type 'Test8', but is declared to return 'Test8_complete *'}}
229- (Test8_complete*) init55 { return 0; } // expected-error {{init methods must return a type related to the receiver type}}
230@end
231
232@class Test9_incomplete;
233@interface Test9
234- (Test9_incomplete*) init1; // expected-error {{init methods must return a type related to the receiver type}}
235- (Test9_incomplete*) init2;
236@end
237id test9(Test9 *v) {
238  return [v init1];
239}
240
241// Test that the inference rules are different for fast enumeration variables.
242void test10(id collection) {
243  for (id x in collection) {
244    __strong id *ptr = &x; // expected-warning {{initializing '__strong id *' with an expression of type 'const __strong id *' discards qualifiers}}
245  }
246
247  for (__strong id x in collection) {
248    __weak id *ptr = &x; // expected-error {{initializing '__weak id *' with an expression of type '__strong id *' changes retain/release properties of pointer}}
249  }
250}
251
252// rdar://problem/9078626
253#define nil ((void*) 0)
254void test11(id op, void *vp) {
255  _Bool b;
256  b = (op == nil);
257  b = (nil == op);
258
259  b = (vp == nil);
260  b = (nil == vp);
261
262  b = (vp == op); // expected-error {{implicit conversion of an Objective-C pointer to 'void *'}}
263  b = (op == vp); // expected-error {{implicit conversion of a non-Objective-C pointer type 'void *' to 'id'}}
264}
265
266void test12(id collection) {
267  for (id x in collection) {
268    x = 0; // expected-error {{fast enumeration variables can't be modified in ARC by default; declare the variable __strong to allow this}}
269  }
270
271  for (const id x in collection) {
272    x = 0; // expected-error {{read-only variable is not assignable}}
273  }
274
275  for (__strong id x in collection) {
276    x = 0;
277  }
278}
279
280@interface Test13
281- (id) init0;
282- (void) noninit;
283@end
284@implementation Test13
285- (id) init0 {
286  self = 0;
287}
288- (void) noninit {
289  self = 0; // expected-error {{cannot assign to 'self' outside of a method in the init family}}
290}
291@end
292
293// rdar://problem/9172151
294@class Test14A, Test14B;
295void test14() {
296  extern void test14_consume(id *);
297  extern int test14_cond(void);
298  extern float test14_nowriteback(id __autoreleasing const *); // expected-note{{passing argument to parameter here}}
299
300  Test14A *a;
301  Test14B *b;
302  id i;
303  id cla[10];
304  id vla[test14_cond() + 10];
305
306  test14_consume((__strong id*) &a);
307  test14_consume((test14_cond() ? (__strong id*) &b : &i));
308  test14_consume(test14_cond() ? 0 : &a);
309  test14_consume(test14_cond() ? (void*) 0 : (&a));
310  test14_consume(cla); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}}
311  test14_consume(vla); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}}
312  test14_consume(&cla[5]); // expected-error {{passing address of non-scalar object to __autoreleasing parameter for write-back}}
313
314  __strong id *test14_indirect(void);
315  test14_consume(test14_indirect()); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
316
317  extern id test14_global;
318  test14_consume(&test14_global); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
319
320  extern __strong id *test14_global_ptr;
321  test14_consume(test14_global_ptr); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
322
323  static id static_local;
324  test14_consume(&static_local); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
325
326  __weak id* wip;
327  test14_nowriteback(&static_local); // okay, not a write-back.
328  test14_nowriteback(wip); // expected-error{{passing '__weak id *' to parameter of type '__autoreleasing id const *' changes retain/release properties of pointer}}
329}
330
331void test15() {
332  __block __autoreleasing id x; // expected-error {{__block variables cannot have __autoreleasing ownership}}
333}
334
335struct Test16;
336@interface Test16a
337- (void) test16_0: (int) x;
338- (int) test16_1: (int) x; // expected-note {{one possibility}}
339- (int) test16_2: (int) x; // expected-note {{one possibility}}
340- (id) test16_3: (int) x __attribute__((ns_returns_retained)); // expected-note {{one possibility}}
341- (void) test16_4: (int) x __attribute__((ns_consumes_self)); // expected-note {{one possibility}}
342- (void) test16_5: (id) __attribute__((ns_consumed)) x; // expected-note {{one possibility}}
343- (void) test16_6: (id) x;
344@end
345
346@interface Test16b
347- (void) test16_0: (int) x;
348- (int) test16_1: (char*) x; // expected-note {{also found}}
349- (char*) test16_2: (int) x; // expected-note {{also found}}
350- (id) test16_3: (int) x; // expected-note {{also found}}
351- (void) test16_4: (int) x; // expected-note {{also found}}
352- (void) test16_5: (id) x; // expected-note {{also found}}
353- (void) test16_6: (struct Test16 *) x;
354@end
355
356void test16(void) {
357  id v;
358  [v test16_0: 0];
359  [v test16_1: 0]; // expected-error {{multiple methods named 'test16_1:' found with mismatched result, parameter type or attributes}}
360  [v test16_2: 0]; // expected-error {{multiple methods named}}
361  [v test16_3: 0]; // expected-error {{multiple methods named}}
362  [v test16_4: 0]; // expected-error {{multiple methods named}}
363  [v test16_5: 0]; // expected-error {{multiple methods named}}
364  [v test16_6: 0];
365}
366
367@class Test17;
368@protocol Test17p
369- (void) test17;
370+ (void) test17;
371@end
372void test17(void) {
373  Test17 *v0;
374  [v0 test17]; // expected-error {{receiver type 'Test17' for instance message is a forward declaration}}
375
376  Test17<Test17p> *v1;
377  [v1 test17]; // expected-error {{receiver type 'Test17<Test17p>' for instance message is a forward declaration}}
378
379  [Test17 test17]; // expected-error {{receiver 'Test17' for class message is a forward declaration}}
380}
381
382void test18(void) {
383  id x;
384  [x test18]; // expected-error {{no known instance method for selector 'test18'}}
385}
386
387extern struct Test19 *test19a;
388struct Test19 *const test19b = 0;
389void test19(void) {
390  id x;
391  x = (id) test19a; // expected-error {{bridged cast}} \
392  // expected-note{{use __bridge to convert directly (no change in ownership))}} \
393  // expected-note{{use __bridge_transfer to transfer ownership of a +1 'struct Test19 *' into ARC}}
394  x = (id) test19b; // expected-error {{bridged cast}} \
395  // expected-note{{use __bridge to convert directly (no change in ownership)}} \
396  // expected-note{{use __bridge_transfer to transfer ownership of a +1 'struct Test19 *' into ARC}}
397}
398
399// rdar://problem/8951453
400static __thread id test20_implicit; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
401static __thread __strong id test20_strong; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
402static __thread __weak id test20_weak; // expected-error {{thread-local variable has non-trivial ownership: type is '__weak id'}}
403static __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}}
404static __thread __unsafe_unretained id test20_unsafe;
405void test20(void) {
406  static __thread id test20_implicit; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
407  static __thread __strong id test20_strong; // expected-error {{thread-local variable has non-trivial ownership: type is '__strong id'}}
408  static __thread __weak id test20_weak; // expected-error {{thread-local variable has non-trivial ownership: type is '__weak id'}}
409  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}}
410  static __thread __unsafe_unretained id test20_unsafe;
411}
412
413// rdar://9310049
414_Bool fn(id obj) {
415    return (_Bool)obj;
416}
417
418// Check casting w/ ownership qualifiers.
419void test21() {
420  __strong id *sip;
421  (void)(__weak id *)sip; // expected-error{{casting '__strong id *' to type '__weak id *' changes retain/release properties of pointer}}
422  (void)(__weak const id *)sip; // expected-error{{casting '__strong id *' to type '__weak id const *' changes retain/release properties of pointer}}
423  (void)(__autoreleasing id *)sip; // expected-error{{casting '__strong id *' to type '__autoreleasing id *' changes retain/release properties of pointer}}
424  (void)(__autoreleasing const id *)sip; // okay
425}
426
427// rdar://problem/9340462
428void test22(id x[]) { // expected-error {{must explicitly describe intended ownership of an object array parameter}}
429}
430
431// rdar://problem/9400219
432void test23(void) {
433  void *ptr;
434  ptr = @"foo";
435  ptr = (ptr ? @"foo" : 0);
436  ptr = (ptr ? @"foo" : @"bar");
437}
438
439id test24(void) {
440  extern void test24_helper(void);
441  return test24_helper(), (void*) 0;
442}
443
444// rdar://9400841
445@interface Base
446@property (assign) id content;
447@end
448
449@interface Foo : Base
450-(void)test;
451@end
452
453@implementation Foo
454-(void)test {
455	super.content = 0;
456}
457@end
458
459// <rdar://problem/9398437>
460void test25(Class *classes) {
461  Class *other_classes;
462  test25(other_classes);
463}
464
465void test26(id y) {
466  extern id test26_var1;
467  __sync_swap(&test26_var1, 0, y); // expected-error {{cannot perform atomic operation on a pointer to type '__strong id': type has non-trivial ownership}}
468
469  extern __unsafe_unretained id test26_var2;
470  __sync_swap(&test26_var2, 0, y);
471}
472
473@interface Test26
474- (id) init;
475- (id) initWithInt: (int) x;
476@end
477@implementation Test26
478- (id) init { return self; }
479- (id) initWithInt: (int) x {
480  [self init]; // expected-error {{the result of a delegate init call must be immediately returned or assigned to 'self'}}
481  return self;
482}
483@end
484
485// rdar://9525555
486@interface  Test27
487@property id x; // expected-warning {{no 'assign', 'retain', or 'copy' attribute is specified - 'assign' is assumed}} \
488                // expected-warning {{default property attribute 'assign' not appropriate for non-gc object}} \
489                // expected-note {{declared here}}
490@property (readonly) id ro; // expected-note {{declared here}}
491@property (readonly) id custom_ro;
492@property int y;
493@end
494
495@implementation Test27
496@synthesize x; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute}}
497@synthesize ro; // expected-error {{ARC forbids synthesizing a property of an Objective-C object with unspecified storage attribute}}
498@synthesize y;
499-(id)custom_ro { return 0; }
500@end
501
502// rdar://9569264
503@interface Test28
504@property (nonatomic, assign) __strong id a; // expected-error {{unsafe_unretained property 'a' may not also be declared __strong}}
505@end
506
507@interface Test28 ()
508@property (nonatomic, assign) __strong id b; // expected-error {{unsafe_unretained property 'b' may not also be declared __strong}}
509@end
510
511@implementation Test28
512@synthesize a;
513@synthesize b;
514@end
515
516// rdar://9573962
517typedef struct Bark Bark;
518@interface Test29
519@property Bark* P;
520@end
521
522@implementation Test29
523@synthesize P;
524- (id)Meth {
525  Bark** f = &P;
526  return 0;
527}
528@end
529
530// rdar://9495837
531@interface Test30
532+ (id) new;
533- (void)Meth;
534@end
535
536@implementation Test30
537+ (id) new { return 0; }
538- (void) Meth {
539  __weak id x = [Test30 new]; // expected-warning {{assigning retained object to weak variable}}
540  id __unsafe_unretained u = [Test30 new]; // expected-warning {{assigning retained object to unsafe_unretained variable}}
541  id y = [Test30 new];
542  x = [Test30 new]; // expected-warning {{assigning retained object to weak variable}}
543  u = [Test30 new]; // expected-warning {{assigning retained object to unsafe_unretained variable}}
544  y = [Test30 new];
545}
546@end
547
548// rdar://9411838
549@protocol PTest31 @end
550
551int Test31() {
552    Class cls;
553    id ids;
554    id<PTest31> pids;
555    Class<PTest31> pcls;
556
557    int i =  (ids->isa ? 1 : 0); // expected-error {{member reference base type 'id' is not a structure or union}}
558    int j = (pids->isa ? 1 : 0); // expected-error {{member reference base type 'id<PTest31>' is not a structure or union}}
559    int k = (pcls->isa ? i : j); // expected-error {{member reference base type 'Class<PTest31>' is not a structure or union}}
560    return cls->isa ? i : j; // expected-error {{member reference base type 'Class' is not a structure or union}}
561}
562
563// rdar://9612030
564@interface ITest32 {
565@public
566 id ivar;
567}
568@end
569
570id Test32(__weak ITest32 *x) {
571  __weak ITest32 *y;
572  x->ivar = 0; // expected-error {{dereferencing a __weak pointer is not allowed}}
573  return y ? y->ivar     // expected-error {{dereferencing a __weak pointer is not allowed}}
574           : (*x).ivar;  // expected-error {{dereferencing a __weak pointer is not allowed}}
575}
576
577// rdar://9619861
578extern int printf(const char*, ...);
579typedef long intptr_t;
580
581int Test33(id someid) {
582  printf( "Hello%ld", (intptr_t)someid);
583  return (int)someid;
584}
585
586// rdar://9636091
587@interface I34
588@property (nonatomic, retain) id newName __attribute__((ns_returns_not_retained)) ;
589
590@property (nonatomic, retain) id newName1 __attribute__((ns_returns_not_retained)) ;
591- (id) newName1 __attribute__((ns_returns_not_retained));
592
593@property (nonatomic, retain) id newName2 __attribute__((ns_returns_not_retained)); // expected-note {{roperty declared here}}
594- (id) newName2;   // expected-warning {{property declared as returning non-retained objects; getter returning retained objects}}
595@end
596
597@implementation I34
598@synthesize newName;
599
600@synthesize newName1;
601- (id) newName1 { return 0; }
602
603@synthesize newName2;
604@end
605
606void test35(void) {
607  extern void test36_helper(id*);
608  id x;
609  __strong id *xp = 0;
610
611  test36_helper(&x);
612  test36_helper(xp); // expected-error {{passing address of non-local object to __autoreleasing parameter for write-back}}
613
614  // rdar://problem/9665710
615  __block id y;
616  test36_helper(&y);
617  ^{ test36_helper(&y); }();
618
619  __strong int non_objc_type; // expected-warning {{'__strong' only applies to objective-c object or block pointer types}}
620}
621
622void test36(int first, ...) {
623  // <rdar://problem/9758798>
624  __builtin_va_list arglist;
625  __builtin_va_start(arglist, first);
626  id obj = __builtin_va_arg(arglist, id);
627  __builtin_va_end(arglist);
628}
629