llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Corentin Jabot (cor3ntin)

<details>
<summary>Changes</summary>

We should not skip the first argument of static member functions when 
initalizing a conversion sequence for a non-deducible parameter.

---
Full diff: https://github.com/llvm/llvm-project/pull/150893.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaOverload.cpp (+3-3) 
- (modified) clang/test/SemaCXX/cxx2b-deducing-this.cpp (+32) 


``````````diff
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@-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'}}
+}
+
+}

``````````

</details>


https://github.com/llvm/llvm-project/pull/150893
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to