]> granicus.if.org Git - clang/commitdiff
patch to support comparison involving
authorFariborz Jahanian <fjahanian@apple.com>
Sat, 21 Aug 2010 00:10:36 +0000 (00:10 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Sat, 21 Aug 2010 00:10:36 +0000 (00:10 +0000)
objctive-c pointer conversions. Fixes pr7936.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@111699 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaOverload.cpp
test/SemaObjCXX/pointer-to-objc-pointer-conv.mm

index 78014a781ec7efd96f4dde81ea75398037e2c7fe..6108d5261e605f36d3da697e16f7d3b1c61f8ae8 100644 (file)
@@ -4168,11 +4168,18 @@ BuiltinCandidateTypeSet::AddPointerWithMoreQualifiedTypeVariants(QualType Ty,
   // Insert this type.
   if (!PointerTypes.insert(Ty))
     return false;
-
+    
+  QualType PointeeTy;
   const PointerType *PointerTy = Ty->getAs<PointerType>();
-  assert(PointerTy && "type was not a pointer type!");
-
-  QualType PointeeTy = PointerTy->getPointeeType();
+  if (!PointerTy) {
+    if (const ObjCObjectPointerType *PTy = Ty->getAs<ObjCObjectPointerType>())
+      PointeeTy = PTy->getPointeeType();
+    else
+      assert(false && "type was not a pointer type!");
+  }
+  else
+    PointeeTy = PointerTy->getPointeeType();
+  
   // Don't add qualified variants of arrays. For one, they're not allowed
   // (the qualifier would sink to the element type), and for another, the
   // only overload situation where it matters is subscript or pointer +- int,
@@ -4268,8 +4275,9 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty,
   // If we're dealing with an array type, decay to the pointer.
   if (Ty->isArrayType())
     Ty = SemaRef.Context.getArrayDecayedType(Ty);
-
-  if (Ty->getAs<PointerType>()) {
+  if (Ty->isObjCIdType() || Ty->isObjCClassType())
+    PointerTypes.insert(Ty);
+  else if (Ty->getAs<PointerType>() || Ty->getAs<ObjCObjectPointerType>()) {
     // Insert our type, and its more-qualified variants, into the set
     // of types.
     if (!AddPointerWithMoreQualifiedTypeVariants(Ty, VisibleQuals))
index 80383ebfd8a94e01610f4cc259cedde8c836535f..11b02c1c1701a26bfae8d8a6c25a921ebe8ccea4 100644 (file)
@@ -19,3 +19,21 @@ void a() {
 
 }
 
+
+// pr7936
+@interface I1 @end
+
+class Wrapper {
+public:
+  operator id() const { return (id)_value; }
+  operator Class() const { return (Class)_value; }
+  operator I1*() const { return (I1*)_value; }
+
+  bool Compare(id obj) { return *this == obj; }
+  bool CompareClass(Class obj) { return *this == obj; }
+  bool CompareI1(I1* obj) { return *this == obj; }
+
+private:
+  long _value;
+};
+