Skip to content

Commit d803c61

Browse files
authored
[Clang] Fix a regression introduced by #147046 (#150893)
Static functions have an implicit object argument during deduction.
1 parent 2f2df75 commit d803c61

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

clang/lib/Sema/SemaOverload.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8042,8 +8042,8 @@ static void AddTemplateOverloadCandidateImmediately(
80428042

80438043
Candidate.IgnoreObjectArgument =
80448044
isa<CXXMethodDecl>(Candidate.Function) &&
8045-
cast<CXXMethodDecl>(Candidate.Function)
8046-
->isImplicitObjectMemberFunction() &&
8045+
!cast<CXXMethodDecl>(Candidate.Function)
8046+
->isExplicitObjectMemberFunction() &&
80478047
!isa<CXXConstructorDecl>(Candidate.Function);
80488048

80498049
Candidate.ExplicitCallArguments = Args.size();

clang/test/SemaCXX/cxx2b-deducing-this.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,3 +1357,35 @@ void Bar(this int) { // expected-note {{candidate function}}
13571357
}
13581358

13591359
}
1360+
1361+
namespace GH147046_regression {
1362+
1363+
template <typename z> struct ai {
1364+
ai(z::ah);
1365+
};
1366+
1367+
template <typename z> struct ak {
1368+
template <typename am> void an(am, z);
1369+
template <typename am> static void an(am, ai<z>);
1370+
};
1371+
template <typename> struct ao {};
1372+
1373+
template <typename ap>
1374+
auto ar(ao<ap> at) -> decltype(ak<ap>::an(at, 0));
1375+
// expected-note@-1 {{candidate template ignored: substitution failure [with ap = GH147046_regression::ay]: no matching function for call to 'an'}}
1376+
1377+
class aw;
1378+
struct ax {
1379+
typedef int ah;
1380+
};
1381+
struct ay {
1382+
typedef aw ah;
1383+
};
1384+
1385+
ao<ay> az ;
1386+
ai<ax> bd(0);
1387+
void f() {
1388+
ar(az); // expected-error {{no matching function for call to 'ar'}}
1389+
}
1390+
1391+
}

0 commit comments

Comments
 (0)