[cfe-commits] r110950 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/block-type-safety.m test/SemaObjC/comptypes-5.m

Fariborz Jahanian fjahanian at apple.com
Thu Aug 12 13:46:12 PDT 2010


Author: fjahanian
Date: Thu Aug 12 15:46:12 2010
New Revision: 110950

URL: http://llvm.org/viewvc/llvm-project?rev=110950&view=rev
Log:
Fixes block type matching bug. Radar 8302845.

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaObjC/block-type-safety.m
    cfe/trunk/test/SemaObjC/comptypes-5.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=110950&r1=110949&r2=110950&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Aug 12 15:46:12 2010
@@ -4336,7 +4336,7 @@
           // 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;
           }

Modified: cfe/trunk/test/SemaObjC/block-type-safety.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-type-safety.m?rev=110950&r1=110949&r2=110950&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/block-type-safety.m (original)
+++ cfe/trunk/test/SemaObjC/block-type-safety.m Thu Aug 12 15:46:12 2010
@@ -104,3 +104,20 @@
   f4(^(NSArray<P2>* a) { });  // expected-error {{incompatible block pointer types passing 'void (^)(NSArray<P2> *)' to parameter of type 'void (^)(id<P>)'}}
 }
 
+// rdar : //8302845
+ at protocol Foo @end
+
+ at interface Baz @end
+
+ at interface Baz(FooConformance) <Foo>
+ at end
+
+ at implementation Baz @end
+
+int test4 () {
+    id <Foo> (^b)() = ^{ // Doesn't work
+        return (Baz *)0;
+    };
+    return 0;
+}
+

Modified: cfe/trunk/test/SemaObjC/comptypes-5.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/comptypes-5.m?rev=110950&r1=110949&r2=110950&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/comptypes-5.m (original)
+++ cfe/trunk/test/SemaObjC/comptypes-5.m Thu Aug 12 15:46:12 2010
@@ -26,8 +26,8 @@
   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 */
 





More information about the cfe-commits mailing list