summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-27 00:15:41 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-27 00:15:41 +0000
commit231d1c6f8f4e49d997b0c2a968435dbb5a381b4e (patch)
treef3348eb10a322f68651c4d3fa456412d776384df /clang/lib
parentb1ef37589c276452ac3b397fa7dfa5b95ab16b8d (diff)
downloadbcm5719-llvm-231d1c6f8f4e49d997b0c2a968435dbb5a381b4e.tar.gz
bcm5719-llvm-231d1c6f8f4e49d997b0c2a968435dbb5a381b4e.zip
Support block pointer conversions in C++. I'm storing the test case locally until we can enable blocks in C++
llvm-svn: 60133
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 3d9ec8d6cb5..d14d74cb827 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -743,9 +743,24 @@ BuildSimilarlyQualifiedPointerType(const PointerType *FromPtr,
/// 4.10). If so, returns true and places the converted type (that
/// might differ from ToType in its cv-qualifiers at some level) into
/// ConvertedType.
+///
+/// This routine also supports conversions to and from block pointers.
bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
QualType& ConvertedType)
{
+ // Blocks: Block pointers can be converted to void*.
+ if (FromType->isBlockPointerType() && ToType->isPointerType() &&
+ ToType->getAsPointerType()->getPointeeType()->isVoidType()) {
+ ConvertedType = ToType;
+ return true;
+ }
+ // Blocks: A null pointer constant can be converted to a block
+ // pointer type.
+ if (ToType->isBlockPointerType() && From->isNullPointerConstant(Context)) {
+ ConvertedType = ToType;
+ return true;
+ }
+
const PointerType* ToTypePtr = ToType->getAsPointerType();
if (!ToTypePtr)
return false;
OpenPOWER on IntegriCloud