r234545 - [Objective-C Sema] It is permissable to bridge cast to 'id'
Fariborz Jahanian
fjahanian at apple.com
Thu Apr 9 16:39:54 PDT 2015
Author: fjahanian
Date: Thu Apr 9 18:39:53 2015
New Revision: 234545
URL: http://llvm.org/viewvc/llvm-project?rev=234545&view=rev
Log:
[Objective-C Sema] It is permissable to bridge cast to 'id'
of a CFType bridged to some unknown Objective-C type.
rdar://20113785
Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/SemaObjC/arc-bridged-cast.m
Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=234545&r1=234544&r2=234545&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Thu Apr 9 18:39:53 2015
@@ -3380,12 +3380,13 @@ static bool CheckObjCBridgeNSCast(Sema &
return false;
}
}
+ } else if (!castType->isObjCIdType()) {
+ S.Diag(castExpr->getLocStart(), diag::err_objc_cf_bridged_not_interface)
+ << castExpr->getType() << Parm;
+ S.Diag(TDNDecl->getLocStart(), diag::note_declared_at);
+ if (Target)
+ S.Diag(Target->getLocStart(), diag::note_declared_at);
}
- S.Diag(castExpr->getLocStart(), diag::err_objc_cf_bridged_not_interface)
- << castExpr->getType() << Parm;
- S.Diag(TDNDecl->getLocStart(), diag::note_declared_at);
- if (Target)
- S.Diag(Target->getLocStart(), diag::note_declared_at);
return true;
}
return false;
Modified: cfe/trunk/test/SemaObjC/arc-bridged-cast.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-bridged-cast.m?rev=234545&r1=234544&r2=234545&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc-bridged-cast.m (original)
+++ cfe/trunk/test/SemaObjC/arc-bridged-cast.m Thu Apr 9 18:39:53 2015
@@ -80,3 +80,12 @@ void testObjCBridgeId() {
ref = (__bridge_retained CFAnnotatedObjectRef) CreateSomething();
ref = (__bridge_retained CFAnnotatedObjectRef) CreateNSString();
}
+
+// rdar://20113785
+typedef const struct __attribute__((objc_bridge(UIFont))) __CTFont * CTFontRef;
+
+id testObjCBridgeUnknownTypeToId(CTFontRef font) {
+ id x = (__bridge id)font;
+ return x;
+}
+
More information about the cfe-commits
mailing list