Skip to content

Commit a7bc056

Browse files
author
huqizhi
committed
[Clang][Sema] Fix issue on requires expression with templated base class member function
1 parent def6174 commit a7bc056

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,7 @@ Bug Fixes to C++ Support
528528
- Clang now correctly tracks type dependence of by-value captures in lambdas with an explicit
529529
object parameter.
530530
Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), (#GH86398), and (#GH86399).
531+
- Fix a crash in requires expression with templated base class member function. Fixes (#GH84020).
531532

532533
Bug Fixes to AST Handling
533534
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaExpr.cpp

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

77377737
if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
7738-
if (Method->isImplicitObjectMemberFunction())
7738+
if (!isa<RequiresExprBodyDecl>(CurContext) &&
7739+
Method->isImplicitObjectMemberFunction())
77397740
return ExprError(Diag(LParenLoc, diag::err_member_call_without_object)
77407741
<< Fn->getSourceRange() << 0);
77417742

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)