]> granicus.if.org Git - clang/commitdiff
Support conversion from a null pointer constant o any Objective-C object pointer...
authorDouglas Gregor <dgregor@apple.com>
Mon, 22 Dec 2008 20:51:52 +0000 (20:51 +0000)
committerDouglas Gregor <dgregor@apple.com>
Mon, 22 Dec 2008 20:51:52 +0000 (20:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61340 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaObjCXX/overload.mm

index 5fb1b14b98b7b789d6a029f3df197b477b7ff86f..836534951326bb9353b9e10f477415d2e0e4ea45 100644 (file)
@@ -767,6 +767,13 @@ bool Sema::IsPointerConversion(Expr *From, QualType FromType, QualType ToType,
   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()) {
index badba16c42bc456d4c8ed399ab0fc82b507be683..397a471257037775be5d77eaafe36d8101c03c2b 100644 (file)
@@ -76,6 +76,9 @@ void qualid_test(A *a, B *b, C *c) {
   int& i1 = qualid(a);
   int& i2 = qualid(b);
   float& f1 = qualid(c);
+
+  id<P0> p1 = 0;
+  p1 = 0;
 }