[clang] [Clang] Fix a regression introduced by #147046 (PR #150893)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Mon Jul 28 00:22:32 PDT 2025
https://github.com/cor3ntin created https://github.com/llvm/llvm-project/pull/150893
We should not skip the first argument of static member functions when initalizing a conversion sequence for a non-deducible parameter.
>From a8fb90c5f2c87dff630259117ee2fd6d435b709d Mon Sep 17 00:00:00 2001
From: Corentin Jabot <corentinjabot at gmail.com>
Date: Mon, 28 Jul 2025 09:20:28 +0200
Subject: [PATCH] [Clang] Fix a regression introduced by #147046
We should not skip the first argument of static member functions
when initalizing a conversion sequence for a non-deducible parameter.
---
clang/lib/Sema/SemaOverload.cpp | 6 ++--
clang/test/SemaCXX/cxx2b-deducing-this.cpp | 32 ++++++++++++++++++++++
2 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 5dd5b495480d9..5134e77ecf695 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -13093,9 +13093,9 @@ CompleteNonViableCandidate(Sema &S, OverloadCandidate *Cand,
} else if (Cand->Function) {
ParamTypes =
Cand->Function->getType()->castAs<FunctionProtoType>()->getParamTypes();
- if (isa<CXXMethodDecl>(Cand->Function) &&
- !isa<CXXConstructorDecl>(Cand->Function) && !Reversed &&
- !Cand->Function->hasCXXExplicitFunctionObjectParameter()) {
+ if (auto *M = dyn_cast<CXXMethodDecl>(Cand->Function);
+ M && !isa<CXXConstructorDecl>(M) && !Reversed &&
+ M->isImplicitObjectMemberFunction()) {
// Conversion 0 is 'this', which doesn't have a corresponding parameter.
ConvIdx = 1;
if (CSK == OverloadCandidateSet::CSK_Operator &&
diff --git a/clang/test/SemaCXX/cxx2b-deducing-this.cpp b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
index 2253cbb26285e..fcbe0f62e6d4f 100644
--- a/clang/test/SemaCXX/cxx2b-deducing-this.cpp
+++ b/clang/test/SemaCXX/cxx2b-deducing-this.cpp
@@ -1357,3 +1357,35 @@ void Bar(this int) { // expected-note {{candidate function}}
}
}
+
+namespace GH147046_regression {
+
+template <typename z> struct ai {
+ ai(z::ah);
+};
+
+template <typename z> struct ak {
+ template <typename am> void an(am, z);
+ template <typename am> static void an(am, ai<z>);
+};
+template <typename> struct ao {};
+
+template <typename ap>
+auto ar(ao<ap> at) -> decltype(ak<ap>::an(at, 0));
+// expected-note at -1 {{candidate template ignored: substitution failure [with ap = GH147046_regression::ay]: no matching function for call to 'an'}}
+
+class aw;
+struct ax {
+ typedef int ah;
+};
+struct ay {
+ typedef aw ah;
+};
+
+ao<ay> az ;
+ai<ax> bd(0);
+void f() {
+ ar(az); // expected-error {{no matching function for call to 'ar'}}
+}
+
+}
More information about the cfe-commits
mailing list