1 // RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify %s 2 3 #if __has_feature(arc_cf_code_audited) 4 char _global[-1]; // expected-error {{declared as an array with a negative size}} 5 #endif 6 7 typedef const void *CFTypeRef; 8 CFTypeRef CFBridgingRetain(id X); 9 id CFBridgingRelease(CFTypeRef); 10 typedef const struct __CFString *CFStringRef; 11 12 extern CFStringRef CFMakeString0(void); 13 extern CFStringRef CFCreateString0(void); 14 void 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 20 extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained)); 21 extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained)); 22 void 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 33 CF_AUDIT_BEGIN 34 extern CFStringRef CFMakeString2(void); 35 extern CFStringRef CFCreateString2(void) CF_RETURNS_NOT_RETAINED; 36 extern CFStringRef CFMakeString3(void) CF_RETURNS_RETAINED; 37 extern CFStringRef CFCreateString3(void); 38 CF_AUDIT_END 39 void 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