1*0a6a1f1dSLionel Sambuc// RUN: %clang_cc1 -fsyntax-only -x objective-c -fobjc-arc -verify -Wno-objc-root-class %s 2*0a6a1f1dSLionel Sambuc// rdar://15454846 3*0a6a1f1dSLionel Sambuc 4*0a6a1f1dSLionel Sambuctypedef struct __attribute__ ((objc_bridge(NSError))) __CFErrorRef * CFErrorRef; // expected-note 5 {{declared here}} 5*0a6a1f1dSLionel Sambuc 6*0a6a1f1dSLionel Sambuctypedef struct __attribute__ ((objc_bridge(MyError))) __CFMyErrorRef * CFMyErrorRef; // expected-note 1 {{declared here}} 7*0a6a1f1dSLionel Sambuc 8*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(12))) __CFMyColor *CFMyColorRef; // expected-error {{parameter of 'objc_bridge' attribute must be a single name of an Objective-C class}} 9*0a6a1f1dSLionel Sambuc 10*0a6a1f1dSLionel Sambuctypedef struct __attribute__ ((objc_bridge)) __CFArray *CFArrayRef; // expected-error {{'objc_bridge' attribute takes one argument}} 11*0a6a1f1dSLionel Sambuc 12*0a6a1f1dSLionel Sambuctypedef void * __attribute__ ((objc_bridge(NSURL))) CFURLRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}} 13*0a6a1f1dSLionel Sambuc 14*0a6a1f1dSLionel Sambuctypedef void * CFStringRef __attribute__ ((objc_bridge(NSString))); // expected-error {{'objc_bridge' attribute only applies to struct or union}} 15*0a6a1f1dSLionel Sambuc 16*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(NSLocale, NSError))) __CFLocale *CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}} 17*0a6a1f1dSLionel Sambuc 18*0a6a1f1dSLionel Sambuctypedef struct __CFData __attribute__((objc_bridge(NSData))) CFDataRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}} 19*0a6a1f1dSLionel Sambuc 20*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef; 21*0a6a1f1dSLionel Sambuc 22*0a6a1f1dSLionel Sambuctypedef struct __CFSetRef * CFSetRef __attribute__((objc_bridge(NSSet))); // expected-error {{'objc_bridge' attribute only applies to struct or union}}; 23*0a6a1f1dSLionel Sambuc 24*0a6a1f1dSLionel Sambuctypedef union __CFUColor __attribute__((objc_bridge(NSUColor))) * CFUColorRef; // expected-error {{'objc_bridge' attribute only applies to struct or union}}; 25*0a6a1f1dSLionel Sambuc 26*0a6a1f1dSLionel Sambuctypedef union __CFUColor __attribute__((objc_bridge(NSUColor))) *CFUColor1Ref; // expected-error {{'objc_bridge' attribute only applies to struct or union}}; 27*0a6a1f1dSLionel Sambuc 28*0a6a1f1dSLionel Sambuctypedef union __attribute__((objc_bridge(NSUColor))) __CFUPrimeColor XXX; 29*0a6a1f1dSLionel Sambuctypedef XXX *CFUColor2Ref; 30*0a6a1f1dSLionel Sambuc 31*0a6a1f1dSLionel Sambuc@interface I 32*0a6a1f1dSLionel Sambuc{ 33*0a6a1f1dSLionel Sambuc __attribute__((objc_bridge(NSError))) void * color; // expected-error {{'objc_bridge' attribute only applies to struct or union}}; 34*0a6a1f1dSLionel Sambuc} 35*0a6a1f1dSLionel Sambuc@end 36*0a6a1f1dSLionel Sambuc 37*0a6a1f1dSLionel Sambuc@protocol NSTesting @end 38*0a6a1f1dSLionel Sambuc@class NSString; 39*0a6a1f1dSLionel Sambuc 40*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(NSTesting))) __CFError *CFTestingRef; // expected-note {{declared here}} 41*0a6a1f1dSLionel Sambuc 42*0a6a1f1dSLionel Sambucid Test1(CFTestingRef cf) { 43*0a6a1f1dSLionel Sambuc return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka 'struct __CFError *') is bridged to 'NSTesting', which is not an Objective-C class}} \ 44*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFTestingRef' (aka 'struct __CFError *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ 45*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 46*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFTestingRef' (aka 'struct __CFError *') into ARC}} 47*0a6a1f1dSLionel Sambuc} 48*0a6a1f1dSLionel Sambuc 49*0a6a1f1dSLionel Sambuctypedef CFErrorRef CFErrorRef1; 50*0a6a1f1dSLionel Sambuc 51*0a6a1f1dSLionel Sambuctypedef CFErrorRef1 CFErrorRef2; // expected-note 2 {{declared here}} 52*0a6a1f1dSLionel Sambuc 53*0a6a1f1dSLionel Sambuc@protocol P1 @end 54*0a6a1f1dSLionel Sambuc@protocol P2 @end 55*0a6a1f1dSLionel Sambuc@protocol P3 @end 56*0a6a1f1dSLionel Sambuc@protocol P4 @end 57*0a6a1f1dSLionel Sambuc@protocol P5 @end 58*0a6a1f1dSLionel Sambuc 59*0a6a1f1dSLionel Sambuc@interface NSError<P1, P2, P3> @end // expected-note 5 {{declared here}} 60*0a6a1f1dSLionel Sambuc 61*0a6a1f1dSLionel Sambuc@interface MyError : NSError // expected-note 1 {{declared here}} 62*0a6a1f1dSLionel Sambuc@end 63*0a6a1f1dSLionel Sambuc 64*0a6a1f1dSLionel Sambuc@interface NSUColor @end 65*0a6a1f1dSLionel Sambuc 66*0a6a1f1dSLionel Sambuc@class NSString; 67*0a6a1f1dSLionel Sambuc 68*0a6a1f1dSLionel Sambucvoid Test2(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2) { 69*0a6a1f1dSLionel Sambuc (void)(NSString *)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'NSString'}} \ 70*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFErrorRef2' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ 71*0a6a1f1dSLionel Sambuc // expected-note {{__bridge to convert directly (no change in ownership)}} \ 72*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka 'struct __CFErrorRef *') into ARC}} 73*0a6a1f1dSLionel Sambuc (void)(NSError *)cf; // expected-error {{cast of C pointer type 'CFErrorRef2' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'NSError *' requires a bridged cast}} \ 74*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 75*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka 'struct __CFErrorRef *') into ARC}} 76*0a6a1f1dSLionel Sambuc (void)(MyError*)cf; // expected-error {{cast of C pointer type 'CFErrorRef2' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'MyError *' requires a bridged cast}} \ 77*0a6a1f1dSLionel Sambuc // expected-note {{__bridge to convert directly (no change in ownership)}} \ 78*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka 'struct __CFErrorRef *') into ARC}} 79*0a6a1f1dSLionel Sambuc (void)(NSUColor *)cf2; // expected-error {{cast of C pointer type 'CFUColor2Ref' (aka 'union __CFUPrimeColor *') to Objective-C pointer type 'NSUColor *' requires a bridged cast}} \ 80*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 81*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFUColor2Ref' (aka 'union __CFUPrimeColor *') into ARC}} 82*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)ns; // expected-error {{cast of Objective-C pointer type 'NSError *' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 83*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 84*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 85*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)str; // expected-warning {{'NSString' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}} \\ 86*0a6a1f1dSLionel Sambuc // expected-error {{cast of Objective-C pointer type 'NSString *' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 87*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 88*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 89*0a6a1f1dSLionel Sambuc (void)(Class)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'Class'}} \\ 90*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFErrorRef2' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'Class' requires a bridged cast}} \ 91*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 92*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka 'struct __CFErrorRef *') into ARC}} 93*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)c; // expected-warning {{'__unsafe_unretained Class' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *}} \\ 94*0a6a1f1dSLionel Sambuc // expected-error {{cast of Objective-C pointer type 'Class' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 95*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 96*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 97*0a6a1f1dSLionel Sambuc} 98*0a6a1f1dSLionel Sambuc 99*0a6a1f1dSLionel Sambuc 100*0a6a1f1dSLionel Sambucvoid Test3(CFErrorRef cf, NSError *ns) { 101*0a6a1f1dSLionel Sambuc (void)(id)cf; // expected-error {{cast of C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'id' requires a bridged cast}} \ 102*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 103*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef' (aka 'struct __CFErrorRef *') into ARC}} 104*0a6a1f1dSLionel Sambuc (void)(id<P1, P2>)cf; // expected-error {{cast of C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'id<P1,P2>' requires a bridged cast}} \ 105*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 106*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef' (aka 'struct __CFErrorRef *') into ARC}} 107*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P4>)cf; // expected-warning {{'CFErrorRef' (aka 'struct __CFErrorRef *') bridges to NSError, not 'id<P1,P2,P4>'}} \ 108*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') to Objective-C pointer type 'id<P1,P2,P4>' requires a bridged cast}} \ 109*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 110*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef' (aka 'struct __CFErrorRef *') into ARC}} 111*0a6a1f1dSLionel Sambuc} 112*0a6a1f1dSLionel Sambuc 113*0a6a1f1dSLionel Sambucvoid Test4(CFMyErrorRef cf) { 114*0a6a1f1dSLionel Sambuc (void)(id)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') to Objective-C pointer type 'id' requires a bridged cast}} \ 115*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 116*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') into ARC}} 117*0a6a1f1dSLionel Sambuc (void)(id<P1, P2>)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') to Objective-C pointer type 'id<P1,P2>' requires a bridged cast}} \ 118*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 119*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') into ARC}} 120*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3>)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') to Objective-C pointer type 'id<P1,P2,P3>' requires a bridged cast}} \ 121*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 122*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') into ARC}} 123*0a6a1f1dSLionel Sambuc (void)(id<P2, P3>)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') to Objective-C pointer type 'id<P2,P3>' requires a bridged cast}} \ 124*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 125*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') into ARC}} 126*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P4>)cf; // expected-warning {{'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') bridges to MyError, not 'id<P1,P2,P4>'}} \ 127*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') to Objective-C pointer type 'id<P1,P2,P4>' requires a bridged cast}} \ 128*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 129*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') into ARC}} 130*0a6a1f1dSLionel Sambuc} 131*0a6a1f1dSLionel Sambuc 132*0a6a1f1dSLionel Sambucvoid Test5(id<P1, P2, P3> P123, id ID, id<P1, P2, P3, P4> P1234, id<P1, P2> P12, id<P2, P3> P23) { 133*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)ID; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 134*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 135*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 136*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P123; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3>' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 137*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 138*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 139*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P1234; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3,P4>' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 140*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 141*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 142*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P12; // expected-error {{cast of Objective-C pointer type 'id<P1,P2>' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 143*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 144*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 145*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P23; // expected-error {{cast of Objective-C pointer type 'id<P2,P3>' to C pointer type 'CFErrorRef' (aka 'struct __CFErrorRef *') requires a bridged cast}} \ 146*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 147*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 148*0a6a1f1dSLionel Sambuc} 149*0a6a1f1dSLionel Sambuc 150*0a6a1f1dSLionel Sambucvoid Test6(id<P1, P2, P3> P123, id ID, id<P1, P2, P3, P4> P1234, id<P1, P2> P12, id<P2, P3> P23) { 151*0a6a1f1dSLionel Sambuc 152*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)ID; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') requires a bridged cast}} \ 153*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 154*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *')}} 155*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P123; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3>' to C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') requires a bridged cast}} \ 156*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 157*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *')}} 158*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P1234; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3,P4>' to C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') requires a bridged cast}} \ 159*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 160*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *')}} 161*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P12; // expected-error {{cast of Objective-C pointer type 'id<P1,P2>' to C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') requires a bridged cast}} \ 162*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 163*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *')}} 164*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P23; // expected-error {{cast of Objective-C pointer type 'id<P2,P3>' to C pointer type 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *') requires a bridged cast}} \ 165*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 166*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka 'struct __CFMyErrorRef *')}} 167*0a6a1f1dSLionel Sambuc} 168*0a6a1f1dSLionel Sambuc 169*0a6a1f1dSLionel Sambuctypedef struct __attribute__ ((objc_bridge(MyPersonalError))) __CFMyPersonalErrorRef * CFMyPersonalErrorRef; // expected-note 1 {{declared here}} 170*0a6a1f1dSLionel Sambuc 171*0a6a1f1dSLionel Sambuc@interface MyPersonalError : NSError <P4> // expected-note 1 {{declared here}} 172*0a6a1f1dSLionel Sambuc@end 173*0a6a1f1dSLionel Sambuc 174*0a6a1f1dSLionel Sambucvoid Test7(id<P1, P2, P3> P123, id ID, id<P1, P2, P3, P4> P1234, id<P1, P2> P12, id<P2, P3> P23) { 175*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)ID; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') requires a bridged cast}} \ 176*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 177*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *')}} 178*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P123; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3>' to C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') requires a bridged cast}} \ 179*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 180*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *')}} 181*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P1234; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3,P4>' to C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') requires a bridged cast}} \ 182*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 183*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *')}} 184*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P12; // expected-error {{cast of Objective-C pointer type 'id<P1,P2>' to C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') requires a bridged cast}} \ 185*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 186*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *')}} 187*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P23; // expected-error {{cast of Objective-C pointer type 'id<P2,P3>' to C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') requires a bridged cast}} \ 188*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 189*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *')}} 190*0a6a1f1dSLionel Sambuc} 191*0a6a1f1dSLionel Sambuc 192*0a6a1f1dSLionel Sambucvoid Test8(CFMyPersonalErrorRef cf) { 193*0a6a1f1dSLionel Sambuc (void)(id)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') to Objective-C pointer type 'id' requires a bridged cast}} \ 194*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 195*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') into ARC}} 196*0a6a1f1dSLionel Sambuc (void)(id<P1>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1>' requires a bridged cast}} \ 197*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 198*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') into ARC}} 199*0a6a1f1dSLionel Sambuc (void)(id<P1, P2>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2>' requires a bridged cast}} \ 200*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 201*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') into ARC}} 202*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2,P3>' requires a bridged cast}} \ 203*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 204*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') into ARC}} 205*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3, P4>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2,P3,P4>' requires a bridged cast}} \ 206*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 207*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') into ARC}} 208*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3, P4, P5>)cf; // expected-warning {{'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') bridges to MyPersonalError, not 'id<P1,P2,P3,P4,P5>'}} \ 209*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2,P3,P4,P5>' requires a bridged cast}} \ 210*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 211*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') into ARC}} 212*0a6a1f1dSLionel Sambuc} 213*0a6a1f1dSLionel Sambuc 214*0a6a1f1dSLionel Sambucvoid Test9(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2) { 215*0a6a1f1dSLionel Sambuc (void)(__bridge NSString *)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'NSString'}} 216*0a6a1f1dSLionel Sambuc (void)(__bridge NSError *)cf; // okay 217*0a6a1f1dSLionel Sambuc (void)(__bridge MyError*)cf; // okay, 218*0a6a1f1dSLionel Sambuc (void)(__bridge NSUColor *)cf2; // okay 219*0a6a1f1dSLionel Sambuc (void)(__bridge CFErrorRef)ns; // okay 220*0a6a1f1dSLionel Sambuc (void)(__bridge CFErrorRef)str; // expected-warning {{'NSString' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 221*0a6a1f1dSLionel Sambuc (void)(__bridge Class)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'Class'}} 222*0a6a1f1dSLionel Sambuc (void)(__bridge CFErrorRef)c; // expected-warning {{'__unsafe_unretained Class' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}} 223*0a6a1f1dSLionel Sambuc} 224*0a6a1f1dSLionel Sambuc 225*0a6a1f1dSLionel Sambuc// rdar://19157264 226*0a6a1f1dSLionel Sambuc#if __has_feature(objc_bridge_id) 227*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(id))) __CFFoo *CFFooRef; 228*0a6a1f1dSLionel Sambuc#endif 229*0a6a1f1dSLionel Sambuc 230*0a6a1f1dSLionel Sambucid convert(CFFooRef obj) { 231*0a6a1f1dSLionel Sambuc (void)(NSError *)obj; // expected-error {{cast of C pointer type 'CFFooRef' (aka 'struct __CFFoo *') to Objective-C pointer type 'NSError *' requires a bridged cast}} \ 232*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 233*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFFooRef' (aka 'struct __CFFoo *') into ARC}} 234*0a6a1f1dSLionel Sambuc (void) (__bridge NSError *)obj; 235*0a6a1f1dSLionel Sambuc (void) (id)obj; // expected-error {{cast of C pointer type 'CFFooRef' (aka 'struct __CFFoo *') to Objective-C pointer type 'id' requires a bridged cast}} \ 236*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 237*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFFooRef' (aka 'struct __CFFoo *') into ARC}} 238*0a6a1f1dSLionel Sambuc return (__bridge id)obj; 239*0a6a1f1dSLionel Sambuc} 240