blob: 81841fbf1e8980fdf0aa7f7a10353f475b398833 [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
2// DISABLE: mingw32
3// rdar://10387088
4typedef const void * CFTypeRef;
Fariborz Jahanian52b62362012-02-01 22:56:20 +00005CFTypeRef CFBridgingRetain(id X);
6id CFBridgingRelease(CFTypeRef);
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +00007
8extern
9CFTypeRef 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 Jahanian607f5872012-07-27 21:34:23 +000027 // expected-note {{use __bridge to convert directly (no change in ownership)}} \
Fariborz Jahanian52b62362012-02-01 22:56:20 +000028 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000029
30 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 Jahanian607f5872012-07-27 21:34:23 +000031 // expected-note {{use __bridge to convert directly (no change in ownership)}} \
Fariborz Jahanian52b62362012-02-01 22:56:20 +000032 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000033
34 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 Jahanian607f5872012-07-27 21:34:23 +000035 // expected-note {{use __bridge to convert directly (no change in ownership)}} \
Fariborz Jahanian52b62362012-02-01 22:56:20 +000036 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000037
Fariborz Jahanian9c7aed32012-01-31 22:09:44 +000038 result = (id) CFRetain((CFTypeRef)((objc_format)));
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000039
40 result = (id) CFRetain(cf_format); // OK
41}
42@end
43