[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / ARCMT / no-canceling-bridge-to-bridge-cast.m
blob3e440d660c19a820350417343a31fbdc4865f841
1 // RUN: %clang_cc1 -arcmt-action=check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s
2 // rdar://10387088
3 typedef const void * CFTypeRef;
4 CFTypeRef CFBridgingRetain(id X);
5 id CFBridgingRelease(CFTypeRef);
7 extern 
8 CFTypeRef CFRetain(CFTypeRef cf);
10 @interface INTF
12   void *cf_format;
13   id objc_format;
15 @end
17 @interface NSString
18 + (id)stringWithFormat:(NSString *)format;
19 @end
21 @implementation INTF
22 - (void) Meth {
23   NSString *result;
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}}
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}}
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}}
37   result = (id) CFRetain((CFTypeRef)((objc_format)));
39   result = (id) CFRetain(cf_format); // OK
41 @end