Author: erichkeane Date: Tue Jun 12 06:59:32 2018 New Revision: 334503 URL: http://llvm.org/viewvc/llvm-project?rev=334503&view=rev Log: Fix overload resolution between Ptr-To-Member and Bool
As reported here (https://bugs.llvm.org/show_bug.cgi?id=19808) and discovered independently when looking at plum-hall tests, we incorrectly implemented over.ics.rank, which says "A conversion that is not a conversion of a pointer, or pointer to member, to bool is better than another conversion that is such a conversion.". In the current Draft (N4750), this is phrased slightly differently in paragraph 4.1: A conversion that does not convert a pointer, a pointer to member, or std::nullptr_t to bool is better than one that does. The comment on isPointerConversionToBool (the changed function) also confirms that this is the case (note outdated reference): isPointerConversionToBool - Determines whether this conversion is a conversion of a pointer or pointer-to-member to bool. This is used as part of the ranking of standard conversion sequences (C++ 13.3.3.2p4). However, despite this comment, it didn't check isMemberPointerType on the 'FromType', presumably incorrectly assuming that 'isPointerType' matched it. This patch fixes this by adding isMemberPointerType to this function. Additionally, member function pointers are just MemberPointerTypes that point to functions insted of data, so that is fixed in this patch as well. Modified: cfe/trunk/lib/Sema/SemaOverload.cpp cfe/trunk/test/SemaCXX/overload-call.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=334503&r1=334502&r2=334503&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Tue Jun 12 06:59:32 2018 @@ -223,6 +223,7 @@ bool StandardConversionSequence::isPoint // a pointer. if (getToType(1)->isBooleanType() && (getFromType()->isPointerType() || + getFromType()->isMemberPointerType() || getFromType()->isObjCObjectPointerType() || getFromType()->isBlockPointerType() || getFromType()->isNullPtrType() || Modified: cfe/trunk/test/SemaCXX/overload-call.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overload-call.cpp?rev=334503&r1=334502&r2=334503&view=diff ============================================================================== --- cfe/trunk/test/SemaCXX/overload-call.cpp (original) +++ cfe/trunk/test/SemaCXX/overload-call.cpp Tue Jun 12 06:59:32 2018 @@ -667,3 +667,24 @@ namespace ProduceNotesAfterSFINAEFailure void f(void*, A); // expected-note {{candidate function not viable}} void g() { f(1, 2); } // expected-error {{no matching function}} } + +namespace PR19808 { + struct B { + int i; + void bar(); + }; + struct D : public B{}; + + void f(bool); + void f(int D::*); + void f(void (D::*)()); + + void Usage() { + int B::*pmem; + void (B::*pmf)(); + + // These should not be ambiguous. + f(pmem); + f(pmf); + } +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits