-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Clang] Fix a regression introduced by #140576 #140859
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-clang Author: cor3ntin (cor3ntin) ChangesLambda 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:
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
|
Lambda bodies should not be treated as subexpressions of the enclosing scope.
f5e126d to
1e7330b
Compare
|
Thank you; this fixes our build! |
|
Ours too :-) |
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/5754 Here is the relevant piece of the build log for the reference |
Lambda bodies should not be treated as subexpressions of the enclosing scope.
Fixes #140934.