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

Fariborz Jahanian fjahanian at apple.com
Thu Apr 1 12:50:22 PDT 2010


Author: fjahanian
Date: Thu Apr  1 14:50:22 2010
New Revision: 100129

URL: http://llvm.org/viewvc/llvm-project?rev=100129&view=rev
Log:
Relax the typesafty rules of block pointers types which
take'id' or return 'id' in their type. Fixes radar 7814131.

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

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=100129&r1=100128&r2=100129&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Apr  1 14:50:22 2010
@@ -4136,14 +4136,15 @@
 bool ASTContext::canAssignObjCInterfacesInBlockPointer(
                                          const ObjCObjectPointerType *LHSOPT,
                                          const ObjCObjectPointerType *RHSOPT) {
-  if (RHSOPT->isObjCBuiltinType())
+  if (RHSOPT->isObjCBuiltinType() || 
+      LHSOPT->isObjCIdType() || LHSOPT->isObjCQualifiedIdType())
     return true;
   
   if (LHSOPT->isObjCBuiltinType()) {
     return RHSOPT->isObjCBuiltinType() || RHSOPT->isObjCQualifiedIdType();
   }
   
-  if (LHSOPT->isObjCQualifiedIdType() || RHSOPT->isObjCQualifiedIdType())
+  if (RHSOPT->isObjCQualifiedIdType())
     return ObjCQualifiedIdTypesAreCompatible(QualType(LHSOPT,0),
                                              QualType(RHSOPT,0),
                                              false);

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=100129&r1=100128&r2=100129&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/block-type-safety.m (original)
+++ cfe/trunk/test/SemaObjC/block-type-safety.m Thu Apr  1 14:50:22 2010
@@ -34,11 +34,11 @@
 
     r0(^Super* () { return 0; });  // OK
     r0(^Sub* () { return 0; });    // OK, variable of type Super* gets return value of type Sub*
-    r0(^id () { return 0; });  // expected-error {{incompatible block pointer types passing 'id (^)(void)', expected 'Super *(^)()'}}
+    r0(^id () { return 0; });
 
     r1(^Super* () { return 0; });  // expected-error {{incompatible block pointer types passing 'Super *(^)(void)', expected 'Sub *(^)()'}}
     r1(^Sub* () { return 0; });    // OK
-    r1(^id () { return 0; });      // expected-error {{incompatible block pointer types passing 'id (^)(void)', expected 'Sub *(^)()'}}
+    r1(^id () { return 0; }); 
      
     r2(^id<NSObject>() { return 0; });
 }
@@ -60,7 +60,7 @@
 void test2(void) 
 { 
   f0(^(id a) { }); // OK
-  f1(^(A* a) { }); // expected-error {{incompatible block pointer types passing 'void (^)(A *)', expected 'void (^)(id)'}}
+  f1(^(A* a) { });
    f1(^(id<NSObject> a) { });	// OK
 }
 
@@ -80,7 +80,7 @@
 
 // programmer wants to write this:
    -printMyThings1 {
-       [myThings enumerateObjectsWithBlock: ^(MyThing *obj) { // expected-error {{incompatible block pointer types sending 'void (^)(MyThing *)', expected 'void (^)(id)'}}
+       [myThings enumerateObjectsWithBlock: ^(MyThing *obj) {
            [obj printThing];
        }];
    }





More information about the cfe-commits mailing list