Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 2 | // rdar://10387088 |
| 3 | typedef const void * CFTypeRef; |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 4 | CFTypeRef CFBridgingRetain(id X); |
| 5 | id CFBridgingRelease(CFTypeRef); |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 6 | |
| 7 | extern |
| 8 | CFTypeRef CFRetain(CFTypeRef cf); |
| 9 | |
| 10 | @interface INTF |
| 11 | { |
| 12 | void *cf_format; |
| 13 | id objc_format; |
| 14 | } |
| 15 | @end |
| 16 | |
| 17 | @interface NSString |
| 18 | + (id)stringWithFormat:(NSString *)format; |
| 19 | @end |
| 20 | |
| 21 | @implementation INTF |
| 22 | - (void) Meth { |
| 23 | NSString *result; |
| 24 | |
| 25 | result = (id) CFRetain([NSString stringWithFormat:@"PBXLoopMode"]); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ |
| 26 | // expected-note {{use __bridge to convert directly (no change in ownership)}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 27 | // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 28 | |
| 29 | result = (id) CFRetain((id)((objc_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ |
| 30 | // expected-note {{use __bridge to convert directly (no change in ownership)}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 31 | // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 32 | |
| 33 | result = (id) CFRetain((id)((cf_format))); // expected-error {{cast of C pointer type 'CFTypeRef' (aka 'const void *') to Objective-C pointer type 'id' requires a bridged cast}} \ |
| 34 | // expected-note {{use __bridge to convert directly (no change in ownership)}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 35 | // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}} |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 36 | |
Fariborz Jahanian | 9c7aed3 | 2012-01-31 22:09:44 +0000 | [diff] [blame] | 37 | result = (id) CFRetain((CFTypeRef)((objc_format))); |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 38 | |
| 39 | result = (id) CFRetain(cf_format); // OK |
| 40 | } |
| 41 | @end |
| 42 | |