Skip to content

Commit 23a3443

Browse files
author
huqizhi
committed
[Clang][Sema] Fix issue on requires expression with templated base class member function
1 parent 3b5e7c8 commit 23a3443

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7729,7 +7729,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl,
77297729
}
77307730

77317731
if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
7732-
if (Method->isImplicitObjectMemberFunction())
7732+
if (!isa<RequiresExprBodyDecl>(CurContext) &&
7733+
Method->isImplicitObjectMemberFunction())
77337734
return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
77347735
<< Fn->getSourceRange() << 0);
77357736

clang/test/SemaCXX/PR84020.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clang_cc1 -std=c++20 -verify %s
2+
// RUN: %clang_cc1 -std=c++23 -verify %s
3+
// expected-no-diagnostics
4+
5+
struct B {
6+
template <typename S>
7+
void foo();
8+
9+
void bar();
10+
};
11+
12+
template <typename T, typename S>
13+
struct A : T {
14+
auto foo() {
15+
static_assert(requires { T::template foo<S>(); });
16+
static_assert(requires { T::bar(); });
17+
}
18+
};
19+
20+
int main() {
21+
A<B, double> a;
22+
a.foo();
23+
}

0 commit comments

Comments
 (0)