llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Ferdinand Bachmann (Ferdi265) <details> <summary>Changes</summary> This PR fixes #<!-- -->183415. As per [expr.const]/p14.1, only the innermost enclosing function parameter scope matters for determining whether a function or lambda is in an immediate function context. It does not matter whether the parent is an immediate function or not. This fixes assertions on valid programs and miscompilations related to immediate functions being callable from non-immediate contexts due to missed escalation of lambdas to immediate functions. With this fix all examples from the linked issue produce identical behaviour as GCC. I am currently rebuilding Clang/LLVM to then run the full clang test suite to verify I did not break anything. This is my first LLVM contribution, so please tell me if I have missed anything. --- Full diff: https://github.com/llvm/llvm-project/pull/232458.diff 1 Files Affected: - (modified) clang/lib/Sema/SemaExpr.cpp (+1-9) ``````````diff diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index e29caaab8e3f3..ba12685b96f0f 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -18527,8 +18527,6 @@ void Sema::PushExpressionEvaluationContextForFunction( FD && FD->isConsteval() ? ExpressionEvaluationContext::ImmediateFunctionContext : NewContext); - const Sema::ExpressionEvaluationContextRecord &Parent = - parentEvaluationContext(); Sema::ExpressionEvaluationContextRecord &Current = currentEvaluationContext(); Current.InDiscardedStatement = false; @@ -18546,13 +18544,7 @@ void Sema::PushExpressionEvaluationContextForFunction( Current.InImmediateEscalatingFunctionContext = getLangOpts().CPlusPlus20 && FD->isImmediateEscalating(); - if (isLambdaMethod(FD)) - Current.InImmediateFunctionContext = - FD->isConsteval() || - (isLambdaMethod(FD) && (Parent.isConstantEvaluated() || - Parent.isImmediateFunctionContext())); - else - Current.InImmediateFunctionContext = FD->isConsteval(); + Current.InImmediateFunctionContext = FD->isConsteval(); } } `````````` </details> https://github.com/llvm/llvm-project/pull/232458 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
