1// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fsyntax-only -fblocks -verify %s 2// rdar://10597832 3 4typedef const void *CFTypeRef; 5typedef const struct __CFString *CFStringRef; 6 7@interface NSString 8@end 9 10CFTypeRef CFCreateSomething(); 11CFStringRef CFCreateString(); 12CFTypeRef CFGetSomething(); 13CFStringRef CFGetString(); 14 15id CreateSomething(); 16NSString *CreateNSString(); 17 18void from_cf() { 19 id obj1 = (__bridge_transfer id)CFCreateSomething(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}} 20 id obj2 = (__bridge_transfer NSString*)CFCreateString(); // expected-warning {{'__bridge_transfer' casts have no effect when not using ARC}} 21 (__bridge int*)CFCreateSomething(); // expected-warning {{expression result unused}} 22 id obj3 = (__bridge id)CFGetSomething(); 23 id obj4 = (__bridge NSString*)CFGetString(); 24} 25 26void to_cf(id obj) { 27 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}} 28 CFStringRef cf2 = (__bridge_retained CFStringRef)CreateNSString(); // expected-warning {{'__bridge_retained' casts have no effect when not using ARC}} 29 CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); 30 CFStringRef cf4 = (__bridge CFStringRef)CreateNSString(); 31} 32 33void fixits() { 34 id obj1 = (id)CFCreateSomething(); 35 CFTypeRef cf1 = (CFTypeRef)CreateSomething(); 36} 37 38#pragma clang diagnostic ignored "-Warc-bridge-casts-disallowed-in-nonarc" 39 40void to_cf_ignored(id obj) { 41 CFTypeRef cf1 = (__bridge_retained CFTypeRef)CreateSomething(); // no-warning 42 CFTypeRef cf3 = (__bridge CFTypeRef)CreateSomething(); // no-warning 43} 44