[cfe-commits] r93803 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/pointer-to-objc-pointer-conv.mm

Fariborz Jahanian fjahanian at apple.com
Mon Jan 18 14:59:23 PST 2010


Author: fjahanian
Date: Mon Jan 18 16:59:22 2010
New Revision: 93803

URL: http://llvm.org/viewvc/llvm-project?rev=93803&view=rev
Log:
Allow conversion of pointer to an objective-c pointer to
a similar pointer. Fixes radar 7552179.

Added:
    cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
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=93803&r1=93802&r2=93803&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Mon Jan 18 16:59:22 2010
@@ -1100,7 +1100,7 @@
                                    bool &IncompatibleObjC) {
   if (!getLangOptions().ObjC1)
     return false;
-
+ 
   // First, we handle all conversions on ObjC object pointer types.
   const ObjCObjectPointerType* ToObjCPtr = ToType->getAs<ObjCObjectPointerType>();
   const ObjCObjectPointerType *FromObjCPtr =
@@ -1164,6 +1164,16 @@
     ConvertedType = ToType;
     return true;
   }
+  // Allow conversion of pointee being objective-c pointer to another one;
+  // as in I* to id.
+  if (FromPointeeType->getAs<ObjCObjectPointerType>() &&
+      ToPointeeType->getAs<ObjCObjectPointerType>() &&
+      isObjCPointerConversion(FromPointeeType, ToPointeeType, ConvertedType,
+                              IncompatibleObjC)) {
+    ConvertedType = ToType;
+    return true;
+  }
+  
   // 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

Added: cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm?rev=93803&view=auto

==============================================================================
--- cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm (added)
+++ cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm Mon Jan 18 16:59:22 2010
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+ at interface G
+ at end
+
+ at interface F
+- (void)bar:(id *)objects;
+- (void)foo:(G**)objects;
+ at end
+
+
+void a() {
+	F *b;
+	G **keys;
+	[b bar:keys];
+
+	id *PID;
+	[b foo:PID];
+
+}
+





More information about the cfe-commits mailing list