Home | History | Annotate | Download | only in SemaObjC
      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 typedef const struct __CFString *CFStringRef;
      9 
     10 extern CFStringRef CFMakeString0(void);
     11 extern CFStringRef CFCreateString0(void);
     12 void test0() {
     13   id x;
     14   x = (id) CFMakeString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
     15   x = (id) CFCreateString0(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
     16 }
     17 
     18 extern CFStringRef CFMakeString1(void) __attribute__((cf_returns_not_retained));
     19 extern CFStringRef CFCreateString1(void) __attribute__((cf_returns_retained));
     20 void test1() {
     21   id x;
     22   x = (id) CFMakeString1();
     23   x = (id) CFCreateString1(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
     24 }
     25 
     26 #define CF_AUDIT_BEGIN _Pragma("clang arc_cf_code_audited begin")
     27 #define CF_AUDIT_END _Pragma("clang arc_cf_code_audited end")
     28 #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
     29 #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
     30 
     31 CF_AUDIT_BEGIN
     32 extern CFStringRef CFMakeString2(void);
     33 extern CFStringRef CFCreateString2(void) CF_RETURNS_NOT_RETAINED;
     34 extern CFStringRef CFMakeString3(void) CF_RETURNS_RETAINED;
     35 extern CFStringRef CFCreateString3(void);
     36 CF_AUDIT_END
     37 void test2() {
     38   id x;
     39   x = (id) CFMakeString2();
     40   x = (id) CFCreateString2();
     41   x = (id) CFMakeString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
     42   x = (id) CFCreateString3(); // expected-error {{requires a bridged cast}} expected-note {{__bridge to convert directly}} expected-note {{__bridge_transfer to transfer}}
     43 }
     44