llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) <details> <summary>Changes</summary> Lambda bodies should not be treated as subexpressions of the enclosing scope. --- Full diff: https://github.com/llvm/llvm-project/pull/140859.diff 2 Files Affected: - (modified) clang/lib/Sema/SemaExpr.cpp (+2-3) - (modified) clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp (+8) ``````````diff diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index b18e83b605e4f..5e06c4bf89766 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -17777,13 +17777,12 @@ void Sema::PushExpressionEvaluationContextForFunction( Current.InImmediateEscalatingFunctionContext = getLangOpts().CPlusPlus20 && FD->isImmediateEscalating(); - if (isLambdaMethod(FD)) { - Current.InDiscardedStatement = Parent.isDiscardedStatementContext(); + if (isLambdaMethod(FD)) Current.InImmediateFunctionContext = FD->isConsteval() || (isLambdaMethod(FD) && (Parent.isConstantEvaluated() || Parent.isImmediateFunctionContext())); - } else { + else Current.InImmediateFunctionContext = FD->isConsteval(); } } diff --git a/clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp b/clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp index 20125cc5d4a9c..054defc3470e7 100644 --- a/clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp +++ b/clang/test/CXX/stmt.stmt/stmt.select/stmt.if/p2.cpp @@ -208,6 +208,14 @@ void test() { } } + +void regression() { + if constexpr (false) { + auto lam = []() { return 0; }; + 1 | lam(); + } +} + } #endif `````````` </details> https://github.com/llvm/llvm-project/pull/140859 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits