1 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify -fblocks %s
6 (void)(int*)arg; // expected-error {{cast of an Objective-C pointer to 'int *' is disallowed with ARC}}
8 (void)(__autoreleasing id*)arg; // expected-error {{cast of an Objective-C pointer to '__autoreleasing id *' is disallowed with ARC}}
9 (void)(id*)arg; // expected-error {{cast of an Objective-C pointer to '__strong id *' is disallowed with ARC}}
11 (void)(__autoreleasing id**)voidp_val;
12 (void)(void*)voidp_val;
13 (void)(void**)arg; // expected-error {{cast of an Objective-C pointer to 'void **' is disallowed with ARC}}
14 cvt((void*)arg); // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'void *' requires a bridged cast}} \
15 // expected-error {{implicit conversion of a non-Objective-C pointer type 'void *' to 'id' is disallowed with ARC}} \
16 // expected-note{{use __bridge to convert directly (no change in ownership)}} \
17 // expected-note{{use __bridge_retained to make an ARC object available as a +1 'void *'}}
19 (void)(__strong id**)(0);
20 return arg; // expected-error {{implicit conversion of an Objective-C pointer to 'void *' is disallowed with ARC}}
23 void to_void(__strong id *sip, __weak id *wip,
24 __autoreleasing id *aip,
25 __unsafe_unretained id *uip) {
40 void from_void(void *vp) {
41 __strong id *sip = (__strong id *)vp;
42 __weak id *wip = (__weak id *)vp;
43 __autoreleasing id *aip = (__autoreleasing id *)vp;
44 __unsafe_unretained id *uip = (__unsafe_unretained id *)vp;
46 __strong id **sipp = (__strong id **)vp;
47 __weak id **wipp = (__weak id **)vp;
48 __autoreleasing id **aipp = (__autoreleasing id **)vp;
49 __unsafe_unretained id **uipp = (__unsafe_unretained id **)vp;
51 sip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__strong id *' is disallowed with ARC}}
52 wip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__weak id *' is disallowed with ARC}}
53 aip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__autoreleasing id *' is disallowed with ARC}}
54 uip = vp; // expected-error{{implicit conversion of a non-Objective-C pointer type 'void *' to '__unsafe_unretained id *' is disallowed with ARC}}
57 typedef void (^Block)();
58 typedef void (^Block_strong)() __strong;
59 typedef void (^Block_autoreleasing)() __autoreleasing;
63 void ownership_transfer_in_cast(void *vp, Block *pblk) {
64 __strong NSString **sip = (NSString**)(__strong id *)vp;
65 __weak NSString **wip = (NSString**)(__weak id *)vp;
66 __autoreleasing id *aip = (id*)(__autoreleasing id *)vp;
67 __unsafe_unretained id *uip = (id*)(__unsafe_unretained id *)vp;
69 __strong id **sipp = (id**)(__strong id **)vp;
70 __weak id **wipp = (id**)(__weak id **)vp;
71 __autoreleasing id **aipp = (id**)(__autoreleasing id **)vp;
72 __unsafe_unretained id **uipp = (id**)(__unsafe_unretained id **)vp;
74 Block_strong blk_strong1;
75 Block_strong blk_strong2 = (Block)blk_strong1;
76 Block_autoreleasing *blk_auto = (Block*)pblk;