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 |
| 2 | // DISABLE: mingw32 |
| 3 | // rdar://10387088 |
| 4 | typedef const void * CFTypeRef; |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 5 | CFTypeRef CFBridgingRetain(id X); |
| 6 | id CFBridgingRelease(CFTypeRef); |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 7 | |
| 8 | extern |
| 9 | CFTypeRef CFRetain(CFTypeRef cf); |
| 10 | |
| 11 | @interface INTF |
| 12 | { |
| 13 | void *cf_format; |
| 14 | id objc_format; |
| 15 | } |
| 16 | @end |
| 17 | |
| 18 | @interface NSString |
| 19 | + (id)stringWithFormat:(NSString *)format; |
| 20 | @end |
| 21 | |
| 22 | @implementation INTF |
| 23 | - (void) Meth { |
| 24 | NSString *result; |
| 25 | |
| 26 | 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}} \ |
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}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 30 | // 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] | 31 | |
| 32 | 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}} \ |
Fariborz Jahanian | 52b6236 | 2012-02-01 22:56:20 +0000 | [diff] [blame] | 33 | // 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] | 34 | |
Fariborz Jahanian | 9c7aed3 | 2012-01-31 22:09:44 +0000 | [diff] [blame] | 35 | result = (id) CFRetain((CFTypeRef)((objc_format))); |
Fariborz Jahanian | 2908ffb | 2012-01-31 21:58:23 +0000 | [diff] [blame] | 36 | |
| 37 | result = (id) CFRetain(cf_format); // OK |
| 38 | } |
| 39 | @end |
| 40 | |