Also allow cast of block pointer type to

pointer to an any object. Another variation of
radar 7562285.

llvm-svn: 94052
This commit is contained in:
Fariborz Jahanian 2010-01-21 00:05:09 +00:00
parent fed36b1aa1
commit e4951fdc4b
2 changed files with 26 additions and 0 deletions

View File

@ -1151,6 +1151,13 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
}
ToPointeeType = ToBlockPtr->getPointeeType();
}
else if (FromType->getAs<BlockPointerType>() &&
ToObjCPtr && ToObjCPtr->isObjCBuiltinType()) {
// Objective C++: We're able to convert from a block pointer type to a
// pointer to an any object.
ConvertedType = ToType;
return true;
}
else
return false;

View File

@ -21,3 +21,22 @@ typedef int (^blocktype)(int a, int b);
return (blocktype)c;
}
@end
@interface B {
blocktype a;
blocktype b;
blocktype c;
}
- (id)Meth;
@end
@implementation B
- (id)Meth {
if (a)
return (A*)a; // expected-error {{C-style cast from 'blocktype' (aka 'int (^)(int, int)') to 'A *' is not allowed}}
if (b)
return (id)b;
if (c)
return (Class)b;
}
@end