[cfe-commits] r60133 - /cfe/trunk/lib/Sema/SemaOverload.cpp
Douglas Gregor
doug.gregor at gmail.com
Wed Nov 26 16:15:41 PST 2008
Author: dgregor
Date: Wed Nov 26 18:15:41 2008
New Revision: 60133
URL: http://llvm.org/viewvc/llvm-project?rev=60133&view=rev
Log:
Support block pointer conversions in C++. I'm storing the test case locally until we can enable blocks in C++
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=60133&r1=60132&r2=60133&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Nov 26 18:15:41 2008
@@ -743,9 +743,24 @@
/// 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;
More information about the cfe-commits
mailing list