]> granicus.if.org Git - clang/commitdiff
Fix PR5756 a different, better way: we don't have a "pointer
authorDouglas Gregor <dgregor@apple.com>
Sun, 13 Dec 2009 21:37:05 +0000 (21:37 +0000)
committerDouglas Gregor <dgregor@apple.com>
Sun, 13 Dec 2009 21:37:05 +0000 (21:37 +0000)
conversion to void*" according to C++ [over.ics.rank]p4b2 if the type
we're converting from is not a pointer.

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

lib/Sema/SemaOverload.cpp

index 2f6300d5bcb6ff53cb995fa0617a684dccaf9e40..561cfdb52e0bcf429aa021c1233683beb1360a5f 100644 (file)
@@ -175,7 +175,7 @@ isPointerConversionToVoidPointer(ASTContext& Context) const {
   if (First == ICK_Array_To_Pointer)
     FromType = Context.getArrayDecayedType(FromType);
 
-  if (Second == ICK_Pointer_Conversion)
+  if (Second == ICK_Pointer_Conversion && FromType->isPointerType())
     if (const PointerType* ToPtrType = ToType->getAs<PointerType>())
       return ToPtrType->getPointeeType()->isVoidType();
 
@@ -1723,31 +1723,26 @@ Sema::CompareStandardConversionSequences(const StandardConversionSequence& SCS1,
     if (SCS2.First == ICK_Array_To_Pointer)
       FromType2 = Context.getArrayDecayedType(FromType2);
 
-    if (const PointerType *FromPointer1 = FromType1->getAs<PointerType>())
-      if (const PointerType *FromPointer2 = FromType2->getAs<PointerType>()) {
-        QualType FromPointee1
-          = FromPointer1->getPointeeType().getUnqualifiedType();
-        QualType FromPointee2
-          = FromPointer2->getPointeeType().getUnqualifiedType();
+    QualType FromPointee1
+      = FromType1->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
+    QualType FromPointee2
+      = FromType2->getAs<PointerType>()->getPointeeType().getUnqualifiedType();
 
-        if (IsDerivedFrom(FromPointee2, FromPointee1))
-          return ImplicitConversionSequence::Better;
-        else if (IsDerivedFrom(FromPointee1, FromPointee2))
-          return ImplicitConversionSequence::Worse;
-        
-        // Objective-C++: If one interface is more specific than the
-        // other, it is the better one.
-        const ObjCInterfaceType* FromIface1 
-          = FromPointee1->getAs<ObjCInterfaceType>();
-        const ObjCInterfaceType* FromIface2
-          = FromPointee2->getAs<ObjCInterfaceType>();
-        if (FromIface1 && FromIface1) {
-          if (Context.canAssignObjCInterfaces(FromIface2, FromIface1))
-            return ImplicitConversionSequence::Better;
-          else if (Context.canAssignObjCInterfaces(FromIface1, FromIface2))
-            return ImplicitConversionSequence::Worse;
-        }
-      }
+    if (IsDerivedFrom(FromPointee2, FromPointee1))
+      return ImplicitConversionSequence::Better;
+    else if (IsDerivedFrom(FromPointee1, FromPointee2))
+      return ImplicitConversionSequence::Worse;
+
+    // Objective-C++: If one interface is more specific than the
+    // other, it is the better one.
+    const ObjCInterfaceType* FromIface1 = FromPointee1->getAs<ObjCInterfaceType>();
+    const ObjCInterfaceType* FromIface2 = FromPointee2->getAs<ObjCInterfaceType>();
+    if (FromIface1 && FromIface1) {
+      if (Context.canAssignObjCInterfaces(FromIface2, FromIface1))
+        return ImplicitConversionSequence::Better;
+      else if (Context.canAssignObjCInterfaces(FromIface1, FromIface2))
+        return ImplicitConversionSequence::Worse;
+    }
   }
 
   // Compare based on qualification conversions (C++ 13.3.3.2p3,