blob: 2c47822001e57291e82dcc476be3b799424cdc11 [file] [log] [blame]
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +00001// RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +00002// rdar://10387088
3typedef const void * CFTypeRef;
Fariborz Jahanian52b62362012-02-01 22:56:20 +00004CFTypeRef CFBridgingRetain(id X);
5id CFBridgingRelease(CFTypeRef);
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +00006
7extern
8CFTypeRef 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 Jahanian52b62362012-02-01 22:56:20 +000027 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000028
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 Jahanian52b62362012-02-01 22:56:20 +000031 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000032
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 Jahanian52b62362012-02-01 22:56:20 +000035 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000036
Fariborz Jahanian9c7aed32012-01-31 22:09:44 +000037 result = (id) CFRetain((CFTypeRef)((objc_format)));
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000038
39 result = (id) CFRetain(cf_format); // OK
40}
41@end
42