From: Fariborz Jahanian Date: Thu, 9 Apr 2015 23:39:53 +0000 (+0000) Subject: [Objective-C Sema] It is permissable to bridge cast to 'id' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e9f4eeaf9ce2910d3a214892201d2466608366c;p=clang [Objective-C Sema] It is permissable to bridge cast to 'id' of a CFType bridged to some unknown Objective-C type. rdar://20113785 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234545 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 52a384f7dc..fdd3b98661 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -3380,12 +3380,13 @@ static bool CheckObjCBridgeNSCast(Sema &S, QualType castType, Expr *castExpr, 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; diff --git a/test/SemaObjC/arc-bridged-cast.m b/test/SemaObjC/arc-bridged-cast.m index 9e716f9d40..0ba7792146 100644 --- a/test/SemaObjC/arc-bridged-cast.m +++ b/test/SemaObjC/arc-bridged-cast.m @@ -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; +} +