Author: Qizhi Hu Date: 2024-04-16T09:57:23+08:00 New Revision: 5f680724838188f516d349bd9459710308d721e0
URL: https://github.com/llvm/llvm-project/commit/5f680724838188f516d349bd9459710308d721e0 DIFF: https://github.com/llvm/llvm-project/commit/5f680724838188f516d349bd9459710308d721e0.diff LOG: [Clang][Sema] Fix issue on requires expression with templated base class member function (#85198) Fix https://github.com/llvm/llvm-project/issues/84020 Skip checking implicit object parameter in the context of `RequiresExprBodyDecl`. Co-authored-by: huqizhi <836744...@qq.com> Added: clang/test/SemaCXX/PR84020.cpp Modified: clang/docs/ReleaseNotes.rst clang/lib/Sema/SemaExpr.cpp Removed: ################################################################################ diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index dc108785f6cc99..76701dc723b6c3 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -538,6 +538,7 @@ Bug Fixes to C++ Support object parameter. Fixes (#GH70604), (#GH79754), (#GH84163), (#GH84425), (#GH86054), (#GH86398), and (#GH86399). - Fix a crash when deducing ``auto`` from an invalid dereference (#GH88329). +- Fix a crash in requires expression with templated base class member function. Fixes (#GH84020). Bug Fixes to AST Handling ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 24f354f1c72498..189764cb4b6b08 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -7739,7 +7739,8 @@ ExprResult Sema::BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, } if (CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl)) - if (Method->isImplicitObjectMemberFunction()) + if (!isa<RequiresExprBodyDecl>(CurContext) && + Method->isImplicitObjectMemberFunction()) return ExprError(Diag(LParenLoc, diag::err_member_call_without_object) << Fn->getSourceRange() << 0); diff --git a/clang/test/SemaCXX/PR84020.cpp b/clang/test/SemaCXX/PR84020.cpp new file mode 100644 index 00000000000000..8ea5dcc4527ae7 --- /dev/null +++ b/clang/test/SemaCXX/PR84020.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -std=c++20 -verify %s +// RUN: %clang_cc1 -std=c++23 -verify %s +// expected-no-diagnostics + +struct B { + template <typename S> + void foo(); + + void bar(); +}; + +template <typename T, typename S> +struct A : T { + auto foo() { + static_assert(requires { T::template foo<S>(); }); + static_assert(requires { T::bar(); }); + } +}; + +int main() { + A<B, double> a; + a.foo(); +} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits