[cfe-commits] r111699 - in /cfe/trunk: lib/Sema/SemaOverload.cpp test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
Fariborz Jahanian
fjahanian at apple.com
Fri Aug 20 17:10:36 PDT 2010
Author: fjahanian
Date: Fri Aug 20 19:10:36 2010
New Revision: 111699
URL: http://llvm.org/viewvc/llvm-project?rev=111699&view=rev
Log:
patch to support comparison involving
objctive-c pointer conversions. Fixes pr7936.
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm
Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=111699&r1=111698&r2=111699&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Fri Aug 20 19:10:36 2010
@@ -4168,11 +4168,18 @@
// 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 @@
// 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))
Modified: 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=111699&r1=111698&r2=111699&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm (original)
+++ cfe/trunk/test/SemaObjCXX/pointer-to-objc-pointer-conv.mm Fri Aug 20 19:10:36 2010
@@ -19,3 +19,21 @@
}
+
+// pr7936
+ at 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;
+};
+
More information about the cfe-commits
mailing list