From: Fariborz Jahanian Date: Thu, 12 Aug 2010 20:46:12 +0000 (+0000) Subject: Fixes block type matching bug. Radar 8302845. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=192b1464dce385ac1947eb8258c3a0cd4444c726;p=clang Fixes block type matching bug. Radar 8302845. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110950 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 8051dca5a6..988bedb1c0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -4336,7 +4336,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs, // when comparing an id

on rhs with a static type on lhs, // static class must implement all of id's protocols directly or // indirectly through its super class. - if (lhsID->ClassImplementsProtocol(*I, false)) { + if (lhsID->ClassImplementsProtocol(*I, true)) { match = true; break; } diff --git a/test/SemaObjC/block-type-safety.m b/test/SemaObjC/block-type-safety.m index 402a658f3e..c13e80618d 100644 --- a/test/SemaObjC/block-type-safety.m +++ b/test/SemaObjC/block-type-safety.m @@ -104,3 +104,20 @@ void test3() { f4(^(NSArray* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(NSArray *)' to parameter of type 'void (^)(id

)'}} } +// rdar : //8302845 +@protocol Foo @end + +@interface Baz @end + +@interface Baz(FooConformance) +@end + +@implementation Baz @end + +int test4 () { + id (^b)() = ^{ // Doesn't work + return (Baz *)0; + }; + return 0; +} + diff --git a/test/SemaObjC/comptypes-5.m b/test/SemaObjC/comptypes-5.m index f652f0e1a1..46300e3a53 100644 --- a/test/SemaObjC/comptypes-5.m +++ b/test/SemaObjC/comptypes-5.m @@ -26,8 +26,8 @@ int main() MyOtherClass *obj_c_super_p_q = nil; MyClass *obj_c_cat_p_q = nil; - obj_c_cat_p = obj_id_p; // expected-warning {{assigning to 'MyClass *' from incompatible type 'id'}} - obj_c_super_p = obj_id_p; // expected-warning {{assigning to 'MyOtherClass *' from incompatible type 'id'}} + obj_c_cat_p = obj_id_p; + obj_c_super_p = obj_id_p; obj_id_p = obj_c_cat_p; /* Ok */ obj_id_p = obj_c_super_p; /* Ok */