https://github.com/term-est created 
https://github.com/llvm/llvm-project/pull/214002

Fixes: #169139

Lambda bodies are not subexpressions of their enclosing lambda-expression, so 
they should not inherit its immediate-function context.

This prevents consteval calls inside lambdas used as NTTPs from reaching 
CodeGen as runtime calls.

>From fcba5fc86df76161420027750f6fca5caae34e67 Mon Sep 17 00:00:00 2001
From: term-est <[email protected]>
Date: Tue, 4 Aug 2026 19:23:57 +0300
Subject: [PATCH] [clang] Linker regression with lambda NTTP containing
 consteval function call  #169139

---
 clang/lib/Sema/SemaLambda.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaLambda.cpp b/clang/lib/Sema/SemaLambda.cpp
index bbe93f6ab8a40..91016e3523387 100644
--- a/clang/lib/Sema/SemaLambda.cpp
+++ b/clang/lib/Sema/SemaLambda.cpp
@@ -1601,6 +1601,9 @@ void Sema::ActOnStartOfLambdaDefinition(LambdaIntroducer 
&Intro,
   // cleanups from the enclosing full-expression.
   PushExpressionEvaluationContextForFunction(
       ExpressionEvaluationContext::PotentiallyEvaluated, LSI->CallOperator);
+
+  currentEvaluationContext().InImmediateFunctionContext =
+      LSI->CallOperator->isConsteval();
 }
 
 void Sema::ActOnLambdaError(SourceLocation StartLoc, Scope *CurScope,

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to