https://github.com/IvyXu420 updated https://github.com/llvm/llvm-project/pull/230806
>From fb0ce51643420c0757bbcb9fc9bffbb667d216b5 Mon Sep 17 00:00:00 2001
From: Ivy Xu <ivyxu1337 at gmail.com>
Date: Sat, 10 Oct 2026 23:23:38 +0800
Subject: [PATCH 1/2] Handle non-template function in
`Sema::resolveAddressOfSingleOverloadCandidate` properly
---
clang/docs/ReleaseNotes.md | 3 +++
clang/lib/Sema/SemaOverload.cpp | 12 ++++++++++++
.../over/over.over/p2-resolve-single-template-id.cpp | 12 ++++++++++++
3 files changed, 27 insertions(+)
diff --git a/clang/docs/ReleaseNotes.md b/clang/docs/ReleaseNotes.md
index 77a1e73bc8af6..d676983e42ce5 100644
--- a/clang/docs/ReleaseNotes.md
+++ b/clang/docs/ReleaseNotes.md
@@ -931,6 +931,9 @@ features cannot lower the translation-unit ABI level;
constrained placeholder type (such as `C auto`) whose default argument
contains a lambda. (#GH230539)
+- Fixed a bug where Clang failed to resolve a reference to an overloaded
+ conversion function when one of the overloads was non-template. (#GH230682)
+
#### Bug Fixes to AST Handling
- Fixed a non-deterministic ordering of unused local typedefs that made
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 62b6ad8ffb564..2ca12f7a172e7 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -14375,6 +14375,18 @@ Sema::resolveAddressOfSingleOverloadCandidate(Expr *E, DeclAccessPair &Pair) {
// FD has the same CUDA preference than Result. Continue to check
// constraints.
+ // C++ [over.over]p5:
+ // [...] If more than one function in the set remains, all function
+ // template specializations in the set are eliminated if the set also
+ // contains a function that is not a function template specialization.
+ // [...]
+ if (Result->isFunctionTemplateSpecialization() !=
+ FD->isFunctionTemplateSpecialization()) {
+ if (!FD->isFunctionTemplateSpecialization())
+ FoundBetter();
+ continue;
+ }
+
// C++ [over.over]p5:
// [...] Any given non-template function F0 is eliminated if the set
// contains a second non-template function that is more
diff --git a/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp b/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
index e538b99a1eb0b..260bbd5a8c185 100644
--- a/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
+++ b/clang/test/CXX/over/over.over/p2-resolve-single-template-id.cpp
@@ -189,3 +189,15 @@ namespace member_pointers {
{ bool b = &s.h<int>; } // expected-error {{cannot form member pointer of type 'bool' without '&' and class name}}
}
}
+
+namespace conversion_functions {
+ struct S {
+ operator int();
+
+ template<typename T> operator T();
+};
+
+ void test() {
+ &S::operator int; // expected-warning {{expression result unused}}
+ }
+}
>From 5d2c89802c158771ec66c97bebf216737c433bbe Mon Sep 17 00:00:00 2001
From: Ivy Xu <ivyxu1337 at gmail.com>
Date: Sun, 11 Oct 2026 10:55:09 +0800
Subject: [PATCH 2/2] Fix `PR98671.cpp`
---
clang/test/SemaCXX/PR98671.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/test/SemaCXX/PR98671.cpp b/clang/test/SemaCXX/PR98671.cpp
index f505186735885..fa7f2c21191ed 100644
--- a/clang/test/SemaCXX/PR98671.cpp
+++ b/clang/test/SemaCXX/PR98671.cpp
@@ -11,7 +11,6 @@ struct S1 {
// Ensure that no assertion is raised when overload resolution fails while
// choosing between an operator function template and an operator function.
constexpr auto r = &S1::operator int;
-// expected-error at -1 {{initializer of type '<overloaded function type>'}}
template <typename T>