forked from OSchip/llvm-project
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:
parent
fed36b1aa1
commit
e4951fdc4b
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue