aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-12-23 00:53:59 +0000
committerDouglas Gregor <dgregor@apple.com>2008-12-23 00:53:59 +0000
commit2a7e58dc24b17b1cb900a1ee30ea328d665b1a64 (patch)
tree51bfd1ec306775f99b9e1d06d4e05f677d4e4fac /lib/Sema/SemaOverload.cpp
parent3fc749d899dfc194162128c1a88933148a39b68d (diff)
Add some block-pointer conversions in C++
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61359 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 8463c5d34b..b2130e42f8 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -135,7 +135,7 @@ bool StandardConversionSequence::isPointerConversionToBool() const
// check for their presence as well as checking whether FromType is
// a pointer.
if (ToType->isBooleanType() &&
- (FromType->isPointerType() ||
+ (FromType->isPointerType() || FromType->isBlockPointerType() ||
First == ICK_Array_To_Pointer || First == ICK_Function_To_Pointer))
return true;
@@ -547,7 +547,8 @@ Sema::IsStandardConversion(Expr* From, QualType ToType,
else if (ToType->isBooleanType() &&
(FromType->isArithmeticType() ||
FromType->isEnumeralType() ||
- FromType->isPointerType())) {
+ FromType->isPointerType() ||
+ FromType->isBlockPointerType())) {
SCS.Second = ICK_Boolean_Conversion;
FromType = Context.BoolTy;
} else {
@@ -857,25 +858,33 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
return true;
}
+ // Beyond this point, both types need to be pointers or block pointers.
+ QualType ToPointeeType;
const PointerType* ToTypePtr = ToType->getAsPointerType();
- if (!ToTypePtr)
+ if (ToTypePtr)
+ ToPointeeType = ToTypePtr->getPointeeType();
+ else if (const BlockPointerType *ToBlockPtr = ToType->getAsBlockPointerType())
+ ToPointeeType = ToBlockPtr->getPointeeType();
+ else
return false;
- // Beyond this point, both types need to be pointers.
+ QualType FromPointeeType;
const PointerType *FromTypePtr = FromType->getAsPointerType();
- if (!FromTypePtr)
+ if (FromTypePtr)
+ FromPointeeType = FromTypePtr->getPointeeType();
+ else if (const BlockPointerType *FromBlockPtr
+ = FromType->getAsBlockPointerType())
+ FromPointeeType = FromBlockPtr->getPointeeType();
+ else
return false;
- QualType FromPointeeType = FromTypePtr->getPointeeType();
- QualType ToPointeeType = ToTypePtr->getPointeeType();
-
// Objective C++: We're able to convert from a pointer to an
// interface to a pointer to a different interface.
const ObjCInterfaceType* FromIface = FromPointeeType->getAsObjCInterfaceType();
const ObjCInterfaceType* ToIface = ToPointeeType->getAsObjCInterfaceType();
if (FromIface && ToIface &&
Context.canAssignObjCInterfaces(ToIface, FromIface)) {
- ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+ ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
ToType, Context);
return true;
@@ -887,7 +896,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
// interfaces, which is permitted. However, we're going to
// complain about it.
IncompatibleObjC = true;
- ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
+ ConvertedType = BuildSimilarlyQualifiedPointerType(FromTypePtr,
ToPointeeType,
ToType, Context);
return true;
@@ -924,7 +933,7 @@ bool Sema::isObjCPointerConversion(QualType FromType, QualType ToType,
return true;
}
- // If we have pointers to functions, check whether the only
+ // If we have pointers to functions or blocks, check whether the only
// differences in the argument and result types are in Objective-C
// pointer conversions. If so, we permit the conversion (but
// complain about it).