[cfe-commits] r61340 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/overload.mm

Douglas Gregor dgregor at apple.com
Mon Dec 22 12:51:53 PST 2008


Author: dgregor
Date: Mon Dec 22 14:51:52 2008
New Revision: 61340

URL: http://llvm.org/viewvc/llvm-project?rev=61340&view=rev
Log:
Support conversion from a null pointer constant o any Objective-C object pointer type. Fixes rdar://problem/6463298

Modified:
    cfe/trunk/lib/Sema/SemaOverload.cpp
    cfe/trunk/test/SemaObjCXX/overload.mm

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=61340&r1=61339&r2=61340&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Dec 22 14:51:52 2008
@@ -767,6 +767,13 @@
   if (isObjCPointerConversion(FromType, ToType, ConvertedType, IncompatibleObjC))
     return true;
 
+  // Conversion from a null pointer constant to any Objective-C pointer type. 
+  if (Context.isObjCObjectPointerType(ToType) && 
+      From->isNullPointerConstant(Context)) {
+    ConvertedType = ToType;
+    return true;
+  }
+
   // Blocks: Block pointers can be converted to void*.
   if (FromType->isBlockPointerType() && ToType->isPointerType() &&
       ToType->getAsPointerType()->getPointeeType()->isVoidType()) {

Modified: cfe/trunk/test/SemaObjCXX/overload.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/overload.mm?rev=61340&r1=61339&r2=61340&view=diff

==============================================================================
--- cfe/trunk/test/SemaObjCXX/overload.mm (original)
+++ cfe/trunk/test/SemaObjCXX/overload.mm Mon Dec 22 14:51:52 2008
@@ -76,6 +76,9 @@
   int& i1 = qualid(a);
   int& i2 = qualid(b);
   float& f1 = qualid(c);
+
+  id<P0> p1 = 0;
+  p1 = 0;
 }
 
 





More information about the cfe-commits mailing list