https://github.com/Benjins updated 
https://github.com/llvm/llvm-project/pull/224500

>From 26146a33855691fc1f1cac84dc1d0ebb8b0411f9 Mon Sep 17 00:00:00 2001
From: Benji Smith <[email protected]>
Date: Thu, 17 Sep 2026 21:47:57 -0400
Subject: [PATCH 1/3] [clang][Sema] Fix tautological type check in
 sameFunctionParameterTypeLists

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
---
 clang/lib/Sema/SemaOverload.cpp                  |  2 +-
 .../CXX/over/over.match/over.match.best/p2.cpp   | 16 ++++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

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}}
+  }
+}

>From a5e719234317dfd429ffe0f113bbb762e47b0de5 Mon Sep 17 00:00:00 2001
From: Benji Smith <[email protected]>
Date: Fri, 18 Sep 2026 06:46:15 -0400
Subject: [PATCH 2/3] Update release notes with clang bug fix

---
 clang/docs/ReleaseNotes.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index f4a34a37aff52..3b11b895da535 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -724,6 +724,9 @@ features cannot lower the translation-unit ABI level;
 - Fixed an issue where an explicit specialization of a constexpr variable would
   result in a link error. (#GH219796)
 
+- Fixed ambiguous overload where two non-static member functions with
+  different signatures could be incorrectly considered equivalent. (#G224499)
+
 #### Bug Fixes to AST Handling
 
 - Fixed a non-deterministic ordering of unused local typedefs that made

>From ffd53014b05294c9d7e142ae0d227dca76dee6f7 Mon Sep 17 00:00:00 2001
From: Benji Smith <[email protected]>
Date: Fri, 18 Sep 2026 06:54:31 -0400
Subject: [PATCH 3/3] Update clang/docs/ReleaseNotes.md

Co-authored-by: Younan Zhang <[email protected]>
---
 clang/docs/ReleaseNotes.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 3b11b895da535..a1f24a8caedae 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -725,7 +725,7 @@ features cannot lower the translation-unit ABI level;
   result in a link error. (#GH219796)
 
 - Fixed ambiguous overload where two non-static member functions with
-  different signatures could be incorrectly considered equivalent. (#G224499)
+  different signatures could be incorrectly considered equivalent. (#GH224499)
 
 #### Bug Fixes to AST Handling
 

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to