diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index a2a3992bab..db83405283 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -281,7 +281,8 @@ Sema::ExprResult Sema::ActOnInstanceMessage(ExprTy *receiver, Selector Sel, Context.getCanonicalType(RExpr->getType()).getUnqualifiedType(); // Handle messages to id. - if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType())) { + if (ReceiverCType == Context.getCanonicalType(Context.getObjCIdType()) || + ReceiverCType->getAsBlockPointerType()) { ObjCMethodDecl *Method = InstanceMethodPool[Sel].Method; if (!Method) Method = FactoryMethodPool[Sel].Method; diff --git a/test/Sema/block-as-object.m b/test/Sema/block-as-object.m new file mode 100644 index 0000000000..2bfb9c37e6 --- /dev/null +++ b/test/Sema/block-as-object.m @@ -0,0 +1,12 @@ +// RUN: clang %s -fsyntax-only -verify + +@interface Whatever +- copy; +@end + +typedef long (^MyBlock)(id obj1, id obj2); + +void foo(MyBlock b) { + id bar = [b copy]; +} +