From: Douglas Gregor Date: Sun, 13 Dec 2009 21:37:05 +0000 (+0000) Subject: Fix PR5756 a different, better way: we don't have a "pointer X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=019196975a4e6224c95dd1b7d974a1d729e15945;p=clang Fix PR5756 a different, better way: we don't have a "pointer 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 --- diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 2f6300d5bc..561cfdb52e 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -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()) 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()) - if (const PointerType *FromPointer2 = FromType2->getAs()) { - QualType FromPointee1 - = FromPointer1->getPointeeType().getUnqualifiedType(); - QualType FromPointee2 - = FromPointer2->getPointeeType().getUnqualifiedType(); + QualType FromPointee1 + = FromType1->getAs()->getPointeeType().getUnqualifiedType(); + QualType FromPointee2 + = FromType2->getAs()->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(); - const ObjCInterfaceType* FromIface2 - = FromPointee2->getAs(); - 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(); + const ObjCInterfaceType* FromIface2 = FromPointee2->getAs(); + 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,