blob: a573b9bbc9dee63e4a11b5ae1c727641b0e66756 [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 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}} \
Fariborz Jahanian52b62362012-02-01 22:56:20 +000030 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000031
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 Jahanian52b62362012-02-01 22:56:20 +000033 // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000034
Fariborz Jahanian9c7aed32012-01-31 22:09:44 +000035 result = (id) CFRetain((CFTypeRef)((objc_format)));
Fariborz Jahanian2908ffb2012-01-31 21:58:23 +000036
37 result = (id) CFRetain(cf_format); // OK
38}
39@end
40