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