1// RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s 
2// rdar://10387088
3typedef const void * CFTypeRef;
4CFTypeRef CFBridgingRetain(id X);
5id CFBridgingRelease(CFTypeRef);
6
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)}} \
27								      // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
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)}} \
31					       // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
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)}} \
35                                             // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
36
37  result = (id) CFRetain((CFTypeRef)((objc_format)));
38
39  result = (id) CFRetain(cf_format); // OK
40}
41@end
42
43