diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -271,6 +271,9 @@ (`#60887 `_) - Fix incorrect merging of lambdas across modules. (`#60985 `_) +- Fix assertion hit when template consteval function appears in nested + consteval/constexpr call chain. + (`#61142 `_) Bug Fixes to Compiler Builtins diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -15174,6 +15174,7 @@ PushExpressionEvaluationContext( FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext : ExprEvalContexts.back().Context); + ExprEvalContexts.back().InImmediateFunctionContext = FD->isConsteval(); // Check for defining attributes before the check for redefinition. if (const auto *Attr = FD->getAttr()) { diff --git a/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp b/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp --- a/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp +++ b/clang/test/CodeGenCXX/cxx20-consteval-crash.cpp @@ -116,3 +116,23 @@ } } // namespace GH60166 + +namespace GH61142 { + +template +struct Test { + constexpr static void g() { + f(); + } + consteval static void f() {}; +}; + +consteval void a() { + Test::g(); +} + +void b() { + Test::g(); +} + +} // namespace GH61142