forked from OSchip/llvm-project
Teach Sema::CheckAssignmentConstraints() to allow assignments between id and block pointer types (^{}).
llvm-svn: 56793
This commit is contained in:
parent
82237f2f42
commit
32d072ca45
|
@ -1653,10 +1653,15 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
|
|||
if (isa<PointerType>(rhsType))
|
||||
return CheckPointerTypesForAssignment(lhsType, rhsType);
|
||||
|
||||
if (rhsType->getAsBlockPointerType())
|
||||
if (rhsType->getAsBlockPointerType()) {
|
||||
if (lhsType->getAsPointerType()->getPointeeType()->isVoidType())
|
||||
return BlockVoidPointer;
|
||||
|
||||
|
||||
// Treat block pointers as objects.
|
||||
if (getLangOptions().ObjC1 &&
|
||||
lhsType == Context.getCanonicalType(Context.getObjCIdType()))
|
||||
return Compatible;
|
||||
}
|
||||
return Incompatible;
|
||||
}
|
||||
|
||||
|
@ -1664,6 +1669,11 @@ Sema::CheckAssignmentConstraints(QualType lhsType, QualType rhsType) {
|
|||
if (rhsType->isIntegerType())
|
||||
return IntToPointer;
|
||||
|
||||
// Treat block pointers as objects.
|
||||
if (getLangOptions().ObjC1 &&
|
||||
rhsType == Context.getCanonicalType(Context.getObjCIdType()))
|
||||
return Compatible;
|
||||
|
||||
if (rhsType->isBlockPointerType())
|
||||
return CheckBlockPointerTypesForAssignment(lhsType, rhsType);
|
||||
|
||||
|
|
|
@ -10,3 +10,11 @@ void foo(MyBlock b) {
|
|||
id bar = [b copy];
|
||||
}
|
||||
|
||||
void foo2(id b) {
|
||||
}
|
||||
|
||||
void foo3(void (^block)(void)) {
|
||||
foo2(block);
|
||||
id x;
|
||||
foo(x);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue