Expr *SubExpr) {
TypeSourceInfo *TSInfo = 0;
QualType T = GetTypeFromParser(Type, &TSInfo);
+ if (Kind == OBC_Bridge) {
+ // warn in presense of __bridge casting to or from a toll free bridge cast.
+ ARCConversionTypeClass exprACTC = classifyTypeForARCConversion(SubExpr->getType());
+ ARCConversionTypeClass castACTC = classifyTypeForARCConversion(T);
+ if (castACTC == ACTC_retainable && exprACTC == ACTC_coreFoundation)
+ (void)CheckObjCBridgeNSCast(*this, T, SubExpr);
+ else if (castACTC == ACTC_coreFoundation && exprACTC == ACTC_retainable)
+ (void)CheckObjCBridgeCFCast(*this, T, SubExpr);
+ }
if (!TSInfo)
TSInfo = Context.getTrivialTypeSourceInfo(T, LParenLoc);
return BuildObjCBridgedCast(LParenLoc, Kind, BridgeKeywordLoc, TSInfo,
// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -verify -Wno-objc-root-class %s
// rdar://15454846
-typedef struct __attribute__ ((objc_bridge(NSError))) __CFErrorRef * CFErrorRef; // expected-note 5 {{declared here}}
+typedef struct __attribute__ ((objc_bridge(NSError))) __CFErrorRef * CFErrorRef; // expected-note 7 {{declared here}}
typedef struct __attribute__ ((objc_bridge(MyError))) __CFMyErrorRef * CFMyErrorRef; // expected-note 3 {{declared here}}
typedef CFErrorRef CFErrorRef1;
-typedef CFErrorRef1 CFErrorRef2; // expected-note {{declared here}}
+typedef CFErrorRef1 CFErrorRef2; // expected-note 2 {{declared here}}
@protocol P1 @end
@protocol P2 @end
@protocol P4 @end
@protocol P5 @end
-@interface NSError<P1, P2, P3> @end // expected-note 5 {{declared here}}
+@interface NSError<P1, P2, P3> @end // expected-note 7 {{declared here}}
@interface MyError : NSError // expected-note 3 {{declared here}}
@end
(void)(id<P1, P2, P3, P4, P5>)cf; // expected-warning {{'CFMyPersonalErrorRef' (aka 'struct __CFMyPersonalErrorRef *') bridges to MyPersonalError, not 'id<P1,P2,P3,P4,P5>'}}
}
+void Test9(CFErrorRef2 cf, NSError *ns, NSString *str, Class c, CFUColor2Ref cf2) {
+ (void)(__bridge NSString *)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'NSString'}}
+ (void)(__bridge NSError *)cf; // okay
+ (void)(__bridge MyError*)cf; // okay,
+ (void)(__bridge NSUColor *)cf2; // okay
+ (void)(__bridge CFErrorRef)ns; // okay
+ (void)(__bridge CFErrorRef)str; // expected-warning {{'NSString' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}}
+ (void)(__bridge Class)cf; // expected-warning {{'CFErrorRef2' (aka 'struct __CFErrorRef *') bridges to NSError, not 'Class'}}
+ (void)(__bridge CFErrorRef)c; // expected-warning {{'__unsafe_unretained Class' cannot bridge to 'CFErrorRef' (aka 'struct __CFErrorRef *')}}
+}