Home | History | Annotate | Download | only in ARCMT
      1 // RUN: %clang_cc1 -arcmt-check -triple x86_64-apple-darwin10 -fsyntax-only -x objective-c -verify %s 
      2 // DISABLE: mingw32
      3 // rdar://10387088
      4 typedef const void * CFTypeRef;
      5 CFTypeRef CFBridgingRetain(id X);
      6 id CFBridgingRelease(CFTypeRef);
      7 
      8 extern 
      9 CFTypeRef 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}} \
     27 								      // expected-note {{use __bridge to convert directly (no change in ownership)}} \
     28 								      // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
     29 
     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}} \
     31 					       // expected-note {{use __bridge to convert directly (no change in ownership)}} \
     32 					       // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
     33 
     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}} \
     35 					     // expected-note {{use __bridge to convert directly (no change in ownership)}} \
     36                                              // expected-note {{use CFBridgingRelease call to transfer ownership of a +1 'CFTypeRef' (aka 'const void *') into ARC}}
     37 
     38   result = (id) CFRetain((CFTypeRef)((objc_format)));
     39 
     40   result = (id) CFRetain(cf_format); // OK
     41 }
     42 @end
     43 
     44