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 struct __attribute__((objc_bridge(NSLocale, NSError))) __CFLocale *CFLocaleRef;// expected-error {{use of undeclared identifier 'NSError'}} 13*0a6a1f1dSLionel Sambuc 14*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(NSDictionary))) __CFDictionary * CFDictionaryRef; 15*0a6a1f1dSLionel Sambuc 16*0a6a1f1dSLionel Sambuctypedef union __attribute__((objc_bridge(NSUColor))) __CFUPrimeColor XXX; 17*0a6a1f1dSLionel Sambuctypedef XXX *CFUColor2Ref; 18*0a6a1f1dSLionel Sambuc 19*0a6a1f1dSLionel Sambuc@interface I 20*0a6a1f1dSLionel Sambuc{ 21*0a6a1f1dSLionel Sambuc} 22*0a6a1f1dSLionel Sambuc@end 23*0a6a1f1dSLionel Sambuc 24*0a6a1f1dSLionel Sambuc@protocol NSTesting @end 25*0a6a1f1dSLionel Sambuc@class NSString; 26*0a6a1f1dSLionel Sambuc 27*0a6a1f1dSLionel Sambuctypedef struct __attribute__((objc_bridge(NSTesting))) __CFError *CFTestingRef; // expected-note {{declared here}} 28*0a6a1f1dSLionel Sambuc 29*0a6a1f1dSLionel Sambucid Test1(CFTestingRef cf) { 30*0a6a1f1dSLionel Sambuc return (NSString *)cf; // expected-error {{CF object of type 'CFTestingRef' (aka '__CFError *') is bridged to 'NSTesting', which is not an Objective-C class}} \ 31*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFTestingRef' (aka '__CFError *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ 32*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 33*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFTestingRef' (aka '__CFError *') into ARC}} 34*0a6a1f1dSLionel Sambuc} 35*0a6a1f1dSLionel Sambuc 36*0a6a1f1dSLionel Sambuctypedef CFErrorRef CFErrorRef1; 37*0a6a1f1dSLionel Sambuc 38*0a6a1f1dSLionel Sambuctypedef CFErrorRef1 CFErrorRef2; // expected-note 2 {{declared here}} 39*0a6a1f1dSLionel Sambuc 40*0a6a1f1dSLionel Sambuc@protocol P1 @end 41*0a6a1f1dSLionel Sambuc@protocol P2 @end 42*0a6a1f1dSLionel Sambuc@protocol P3 @end 43*0a6a1f1dSLionel Sambuc@protocol P4 @end 44*0a6a1f1dSLionel Sambuc@protocol P5 @end 45*0a6a1f1dSLionel Sambuc 46*0a6a1f1dSLionel Sambuc@interface NSError<P1, P2, P3> @end // expected-note 5 {{declared here}} 47*0a6a1f1dSLionel Sambuc 48*0a6a1f1dSLionel Sambuc@interface MyError : NSError // expected-note 1 {{declared here}} 49*0a6a1f1dSLionel Sambuc@end 50*0a6a1f1dSLionel Sambuc 51*0a6a1f1dSLionel Sambuc@interface NSUColor @end 52*0a6a1f1dSLionel Sambuc 53*0a6a1f1dSLionel Sambuc@class NSString; 54*0a6a1f1dSLionel Sambuc 55*0a6a1f1dSLionel Sambucvoid Test2(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2) { 56*0a6a1f1dSLionel Sambuc (void)(NSString *)cf; // expected-warning {{'CFErrorRef2' (aka '__CFErrorRef *') bridges to NSError, not 'NSString'}} \ 57*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFErrorRef2' (aka '__CFErrorRef *') to Objective-C pointer type 'NSString *' requires a bridged cast}} \ 58*0a6a1f1dSLionel Sambuc // expected-note {{__bridge to convert directly (no change in ownership)}} \ 59*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka '__CFErrorRef *') into ARC}} 60*0a6a1f1dSLionel Sambuc (void)(NSError *)cf; // expected-error {{cast of C pointer type 'CFErrorRef2' (aka '__CFErrorRef *') to Objective-C pointer type 'NSError *' requires a bridged cast}} \ 61*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 62*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka '__CFErrorRef *') into ARC}} 63*0a6a1f1dSLionel Sambuc (void)(MyError*)cf; // expected-error {{cast of C pointer type 'CFErrorRef2' (aka '__CFErrorRef *') to Objective-C pointer type 'MyError *' requires a bridged cast}} \ 64*0a6a1f1dSLionel Sambuc // expected-note {{__bridge to convert directly (no change in ownership)}} \ 65*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka '__CFErrorRef *') into ARC}} 66*0a6a1f1dSLionel Sambuc (void)(NSUColor *)cf2; // expected-error {{cast of C pointer type 'CFUColor2Ref' (aka '__CFUPrimeColor *') to Objective-C pointer type 'NSUColor *' requires a bridged cast}} \ 67*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 68*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFUColor2Ref' (aka '__CFUPrimeColor *') into ARC}} 69*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)ns; // expected-error {{cast of Objective-C pointer type 'NSError *' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') requires a bridged cast}} \ 70*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 71*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 72*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)str; // expected-warning {{'NSString' cannot bridge to 'CFErrorRef' (aka '__CFErrorRef *')}} \\ 73*0a6a1f1dSLionel Sambuc // expected-error {{cast of Objective-C pointer type 'NSString *' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') 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_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 76*0a6a1f1dSLionel Sambuc (void)(Class)cf; // expected-warning {{'CFErrorRef2' (aka '__CFErrorRef *') bridges to NSError, not 'Class'}} \\ 77*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFErrorRef2' (aka '__CFErrorRef *') to Objective-C pointer type 'Class' requires a bridged cast}} \ 78*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 79*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef2' (aka '__CFErrorRef *') into ARC}} 80*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)c; // expected-warning {{'__unsafe_unretained Class' cannot bridge to 'CFErrorRef' (aka '__CFErrorRef *')}} \ 81*0a6a1f1dSLionel Sambuc // expected-error {{cast of Objective-C pointer type 'Class' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') requires a bridged cast}} \ 82*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 83*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 84*0a6a1f1dSLionel Sambuc} 85*0a6a1f1dSLionel Sambuc 86*0a6a1f1dSLionel Sambuc 87*0a6a1f1dSLionel Sambucvoid Test3(CFErrorRef cf, NSError *ns) { 88*0a6a1f1dSLionel Sambuc (void)(id)cf; // expected-error {{cast of C pointer type 'CFErrorRef' (aka '__CFErrorRef *') to Objective-C pointer type 'id' requires a bridged cast}} \ 89*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 90*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef' (aka '__CFErrorRef *') into ARC}} 91*0a6a1f1dSLionel Sambuc (void)(id<P1, P2>)cf; // expected-error {{cast of C pointer type 'CFErrorRef' (aka '__CFErrorRef *') to Objective-C pointer type 'id<P1,P2>' requires a bridged cast}} \ 92*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 93*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef' (aka '__CFErrorRef *') into ARC}} 94*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P4>)cf; // expected-warning {{'CFErrorRef' (aka '__CFErrorRef *') bridges to NSError, not 'id<P1,P2,P4>'}} \ 95*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFErrorRef' (aka '__CFErrorRef *') to Objective-C pointer type 'id<P1,P2,P4>' requires a bridged cast}} \ 96*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 97*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFErrorRef' (aka '__CFErrorRef *') into ARC}} 98*0a6a1f1dSLionel Sambuc} 99*0a6a1f1dSLionel Sambuc 100*0a6a1f1dSLionel Sambucvoid Test4(CFMyErrorRef cf) { 101*0a6a1f1dSLionel Sambuc (void)(id)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') 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 'CFMyErrorRef' (aka '__CFMyErrorRef *') into ARC}} 104*0a6a1f1dSLionel Sambuc (void)(id<P1, P2>)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') 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 'CFMyErrorRef' (aka '__CFMyErrorRef *') into ARC}} 107*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3>)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') to Objective-C pointer type 'id<P1,P2,P3>' requires a bridged cast}} \ 108*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 109*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka '__CFMyErrorRef *') into ARC}} 110*0a6a1f1dSLionel Sambuc (void)(id<P2, P3>)cf; // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') to Objective-C pointer type 'id<P2,P3>' requires a bridged cast}} \ 111*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 112*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyErrorRef' (aka '__CFMyErrorRef *') into ARC}} 113*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P4>)cf; // expected-warning {{'CFMyErrorRef' (aka '__CFMyErrorRef *') bridges to MyError, not 'id<P1,P2,P4>'}} \ 114*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') to Objective-C pointer type 'id<P1,P2,P4>' 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 '__CFMyErrorRef *') into ARC}} 117*0a6a1f1dSLionel Sambuc} 118*0a6a1f1dSLionel Sambuc 119*0a6a1f1dSLionel Sambucvoid Test5(id<P1, P2, P3> P123, id ID, id<P1, P2, P3, P4> P1234, id<P1, P2> P12, id<P2, P3> P23) { 120*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)ID; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') 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_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 123*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P123; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3>' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') 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_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 126*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P1234; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3,P4>' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') requires a bridged cast}} \ 127*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 128*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 129*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P12; // expected-error {{cast of Objective-C pointer type 'id<P1,P2>' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') requires a bridged cast}} \ 130*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 131*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 132*0a6a1f1dSLionel Sambuc (void)(CFErrorRef)P23; // expected-error {{cast of Objective-C pointer type 'id<P2,P3>' to C pointer type 'CFErrorRef' (aka '__CFErrorRef *') requires a bridged cast}} \ 133*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 134*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFErrorRef' (aka '__CFErrorRef *')}} 135*0a6a1f1dSLionel Sambuc} 136*0a6a1f1dSLionel Sambuc 137*0a6a1f1dSLionel Sambucvoid Test6(id<P1, P2, P3> P123, id ID, id<P1, P2, P3, P4> P1234, id<P1, P2> P12, id<P2, P3> P23) { 138*0a6a1f1dSLionel Sambuc 139*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)ID; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') 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 'CFMyErrorRef' (aka '__CFMyErrorRef *')}} 142*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P123; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3>' to C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') 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 'CFMyErrorRef' (aka '__CFMyErrorRef *')}} 145*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P1234; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3,P4>' to C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') 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 'CFMyErrorRef' (aka '__CFMyErrorRef *')}} 148*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P12; // expected-error {{cast of Objective-C pointer type 'id<P1,P2>' to C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') requires a bridged cast}} \ 149*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 150*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka '__CFMyErrorRef *')}} 151*0a6a1f1dSLionel Sambuc (void)(CFMyErrorRef)P23; // expected-error {{cast of Objective-C pointer type 'id<P2,P3>' to C pointer type 'CFMyErrorRef' (aka '__CFMyErrorRef *') requires a bridged cast}} \ 152*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 153*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyErrorRef' (aka '__CFMyErrorRef *')}} 154*0a6a1f1dSLionel Sambuc} 155*0a6a1f1dSLionel Sambuc 156*0a6a1f1dSLionel Sambuctypedef struct __attribute__ ((objc_bridge(MyPersonalError))) __CFMyPersonalErrorRef * CFMyPersonalErrorRef; // expected-note 1 {{declared here}} 157*0a6a1f1dSLionel Sambuc 158*0a6a1f1dSLionel Sambuc@interface MyPersonalError : NSError <P4> // expected-note 1 {{declared here}} 159*0a6a1f1dSLionel Sambuc@end 160*0a6a1f1dSLionel Sambuc 161*0a6a1f1dSLionel Sambucvoid Test7(id<P1, P2, P3> P123, id ID, id<P1, P2, P3, P4> P1234, id<P1, P2> P12, id<P2, P3> P23) { 162*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)ID; // expected-error {{cast of Objective-C pointer type 'id' to C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') requires a bridged cast}} \ 163*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 164*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *')}} 165*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P123; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3>' to C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') requires a bridged cast}} \ 166*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 167*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *')}} 168*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P1234; // expected-error {{cast of Objective-C pointer type 'id<P1,P2,P3,P4>' to C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') requires a bridged cast}} \ 169*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 170*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *')}} 171*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P12; // expected-error {{cast of Objective-C pointer type 'id<P1,P2>' to C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') requires a bridged cast}} \ 172*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 173*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *')}} 174*0a6a1f1dSLionel Sambuc (void)(CFMyPersonalErrorRef)P23; // expected-error {{cast of Objective-C pointer type 'id<P2,P3>' to C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') requires a bridged cast}} \ 175*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 176*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_retained to make an ARC object available as a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *')}} 177*0a6a1f1dSLionel Sambuc} 178*0a6a1f1dSLionel Sambuc 179*0a6a1f1dSLionel Sambucvoid Test8(CFMyPersonalErrorRef cf) { 180*0a6a1f1dSLionel Sambuc (void)(id)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') to Objective-C pointer type 'id' requires a bridged cast}} \ 181*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 182*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') into ARC}} 183*0a6a1f1dSLionel Sambuc (void)(id<P1>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1>' requires a bridged cast}} \ 184*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 185*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') into ARC}} 186*0a6a1f1dSLionel Sambuc (void)(id<P1, P2>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2>' requires a bridged cast}} \ 187*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 188*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') into ARC}} 189*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2,P3>' requires a bridged cast}} \ 190*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 191*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') into ARC}} 192*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3, P4>)cf; // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2,P3,P4>' requires a bridged cast}} \ 193*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge to convert directly (no change in ownership)}} \ 194*0a6a1f1dSLionel Sambuc // expected-note {{use __bridge_transfer to transfer ownership of a +1 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') into ARC}} 195*0a6a1f1dSLionel Sambuc (void)(id<P1, P2, P3, P4, P5>)cf; // expected-warning {{'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') bridges to MyPersonalError, not 'id<P1,P2,P3,P4,P5>'}} \ 196*0a6a1f1dSLionel Sambuc // expected-error {{cast of C pointer type 'CFMyPersonalErrorRef' (aka '__CFMyPersonalErrorRef *') to Objective-C pointer type 'id<P1,P2,P3,P4,P5>' 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 '__CFMyPersonalErrorRef *') into ARC}} 199*0a6a1f1dSLionel Sambuc} 200*0a6a1f1dSLionel Sambuc 201*0a6a1f1dSLionel Sambucvoid Test9(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2) { 202*0a6a1f1dSLionel Sambuc (void)(__bridge NSString *)cf; // expected-warning {{'CFErrorRef2' (aka '__CFErrorRef *') bridges to NSError, not 'NSString'}} 203*0a6a1f1dSLionel Sambuc (void)(__bridge NSError *)cf; // okay 204*0a6a1f1dSLionel Sambuc (void)(__bridge MyError*)cf; // okay, 205*0a6a1f1dSLionel Sambuc (void)(__bridge NSUColor *)cf2; // okay 206*0a6a1f1dSLionel Sambuc (void)(__bridge CFErrorRef)ns; // okay 207*0a6a1f1dSLionel Sambuc (void)(__bridge CFErrorRef)str; // expected-warning {{'NSString' cannot bridge to 'CFErrorRef' (aka '__CFErrorRef *')}} 208*0a6a1f1dSLionel Sambuc (void)(__bridge Class)cf; // expected-warning {{'CFErrorRef2' (aka '__CFErrorRef *') bridges to NSError, not 'Class'}} 209*0a6a1f1dSLionel Sambuc (void)(__bridge CFErrorRef)c; // expected-warning {{'__unsafe_unretained Class' cannot bridge to 'CFErrorRef' (aka '__CFErrorRef *')}} 210*0a6a1f1dSLionel Sambuc} 211