1// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s 2 3#if __has_feature(arc_cf_code_audited) 4char _global[-1]; // expected-error {{declared as an array with a negative size}} 5#endif 6 7typedef const void *CFTypeRef; 8CFTypeRef CFBridgingRetain(id X); 9id CFBridgingRelease(CFTypeRef); 10typedef const struct __CFString *CFStringRef; 11 12extern CFStringRef CFMakeString0(void); 13extern CFStringRef CFCreateString0(void); 14void test0() { 15 id x; 16 x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} 17 x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} 18} 19 20extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained)); 21extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained)); 22void test1() { 23 id x; 24 x = (id) CFMakeString1(); 25 x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} 26} 27 28#define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin") 29#define CF_AUDIT_END _Pragma("clang arc_cf_code_audited end") 30#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) 31#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained)) 32 33CF_AUDIT_BEGIN 34extern CFStringRef CFMakeString2(void); 35extern CFStringRef CFCreateString2(void) CF_RETURNS_NOT_RETAINED; 36extern CFStringRef CFMakeString3(void) CF_RETURNS_RETAINED; 37extern CFStringRef CFCreateString3(void); 38CF_AUDIT_END 39void test2() { 40 id x; 41 x = (id) CFMakeString2(); 42 x = (id) CFCreateString2(); 43 x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} 44 x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{CFBridgingRelease call to transfer}} 45} 46