llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Benji Smith (Benjins) <details> <summary>Changes</summary> hasSameType had duplicate parameters, which meant we weren't actually checking if the function signatures are equal, so in the case they aren't we could incorrectly accept ambiguous overload resolutions. Fixes https://github.com/llvm/llvm-project/issues/224499 --- Full diff: https://github.com/llvm/llvm-project/pull/224500.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaOverload.cpp (+1-1) - (modified) clang/test/CXX/over/over.match/over.match.best/p2.cpp (+16) ``````````diff diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp index a90c118b682fd..e12b727274408 100644 --- a/clang/lib/Sema/SemaOverload.cpp +++ b/clang/lib/Sema/SemaOverload.cpp @@ -10980,7 +10980,7 @@ static bool sameFunctionParameterTypeLists(Sema &S, FunctionDecl *Fn1, if (Mem1->isInstance() && Mem2->isInstance() && !S.getASTContext().hasSameType( Mem1->getFunctionObjectParameterReferenceType(), - Mem1->getFunctionObjectParameterReferenceType())) + Mem2->getFunctionObjectParameterReferenceType())) return false; } return true; diff --git a/clang/test/CXX/over/over.match/over.match.best/p2.cpp b/clang/test/CXX/over/over.match/over.match.best/p2.cpp index e0f7dfb6a4065..59b545ea637a2 100644 --- a/clang/test/CXX/over/over.match/over.match.best/p2.cpp +++ b/clang/test/CXX/over/over.match/over.match.best/p2.cpp @@ -18,3 +18,19 @@ namespace PR44761 { // expected-note@#2 {{candidate function has been explicitly deleted}} // expected-note@#2 {{candidate function (with reversed parameter order) has been explicitly deleted}} } + +namespace ambiguous_resolution { + template<class T> struct S { + int f() const requires true { return 1; } // #S-const-overload + int f() volatile { return 2; } // #S-volatile-overload + }; + int test() { + // Here, we have two overloads: `const S&` and `volatile S&` + // Neither conversion should win the tie-break, and so we should + // instead error on ambiguous overloads + S<int> s; return s.f(); + // expected-error@-1 {{call to member function 'f' is ambiguous}} + // expected-note@#S-const-overload {{candidate function}} + // expected-note@#S-volatile-overload {{candidate function}} + } +} `````````` </details> https://github.com/llvm/llvm-project/pull/224500 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
