1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fobjc-arc -fblocks -verify %s 2 3typedef const void *CFTypeRef; 4typedef const struct __CFString *CFStringRef; 5 6@interface NSString 7@end 8 9CFTypeRef CFCreateSomething(); 10CFStringRef CFCreateString(); 11CFTypeRef CFGetSomething(); 12CFStringRef CFGetString(); 13 14id CreateSomething(); 15NSString *CreateNSString(); 16 17template<typename IdType, typename StringType, typename IntPtrType> 18void from_cf() { 19 id obj1 = (__bridge_transfer IdType)CFCreateSomething(); 20 id obj2 = (__bridge_transfer StringType)CFCreateString(); 21 (__bridge IntPtrType)CFCreateSomething(); // expected-error{{incompatible types casting 'CFTypeRef' (aka 'const void *') to 'int *' with a __bridge cast}} 22 id obj3 = (__bridge IdType)CFGetSomething(); 23 id obj4 = (__bridge StringType)CFGetString(); 24} 25 26template void from_cf<id, NSString*, int*>(); // expected-note{{in instantiation of function template specialization}} 27 28template<typename IdType, typename StringType> 29void to_cf(id obj) { 30 CFTypeRef cf1 = (__bridge_retained IdType)CreateSomething(); 31 CFStringRef cf2 = (__bridge_retained StringType)CreateNSString(); 32 CFTypeRef cf3 = (__bridge IdType)CreateSomething(); 33 CFStringRef cf4 = (__bridge StringType)CreateNSString(); 34} 35 36template void to_cf<CFTypeRef, CFStringRef>(id); 37