]> granicus.if.org Git - clang/commitdiff
Fixes block type matching bug. Radar 8302845.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 12 Aug 2010 20:46:12 +0000 (20:46 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 12 Aug 2010 20:46:12 +0000 (20:46 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110950 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTContext.cpp
test/SemaObjC/block-type-safety.m
test/SemaObjC/comptypes-5.m

index 8051dca5a6a7cca15fa2aa83a918a9745143ad45..988bedb1c0386e5928783de7c2368fe375c1e8b7 100644 (file)
@@ -4336,7 +4336,7 @@ bool ASTContext::ObjCQualifiedIdTypesAreCompatible(QualType lhs, QualType rhs,
           // when comparing an id<P> 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;
           }
index 402a658f3e354dd5c8e7bd1c7da540d1de776057..c13e80618d51106df78d68a0a56bd0c70baa891d 100644 (file)
@@ -104,3 +104,20 @@ void test3() {
   f4(^(NSArray<P2>* a) { });  // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}}
 }
 
+// rdar : //8302845
+@protocol Foo @end
+
+@interface Baz @end
+
+@interface Baz(FooConformance) <Foo>
+@end
+
+@implementation Baz @end
+
+int test4 () {
+    id <Foo> (^b)() = ^{ // Doesn't work
+        return (Baz *)0;
+    };
+    return 0;
+}
+
index f652f0e1a1f344bd1df0a0260927ec5503d1b579..46300e3a5309e8795160ae1218125105aefe428c 100644 (file)
@@ -26,8 +26,8 @@ int main()
   MyOtherClass<MyProtocol> *obj_c_super_p_q = nil;
   MyClass<MyProtocol> *obj_c_cat_p_q = nil;
 
-  obj_c_cat_p = obj_id_p;   // expected-warning {{assigning to 'MyClass *' from incompatible type 'id<MyProtocol>'}}
-  obj_c_super_p = obj_id_p; // expected-warning {{assigning to 'MyOtherClass *' from incompatible type 'id<MyProtocol>'}} 
+  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 */