[PATCH] D112089: consteval if does not form a discarded statement
Richard Smith - zygoloid via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 19 14:05:55 PDT 2021
rsmith added inline comments.
================
Comment at: clang/lib/Parse/ParseStmt.cpp:1445-1450
Sema::ExpressionEvaluationContext Context =
Sema::ExpressionEvaluationContext::DiscardedStatement;
- if (NotLocation.isInvalid() && IsConsteval)
+ if (NotLocation.isInvalid() && IsConsteval) {
Context = Sema::ExpressionEvaluationContext::ImmediateFunctionContext;
+ ShouldEnter = true;
+ }
----------------
It looks to me like this is still incorrectly updating the context in some cases. We shouldn't enter an immediate function context if we're already in a discarded statement context. For example, Clang currently rejects this valid code:
```
auto f() {
if constexpr (false) {
if consteval {
return 0;
}
}
return 0.0;
}
```
... and it looks like it still will after this change. I think we should not enter a new context here if the existing context is a discarded statement context.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112089/new/
https://reviews.llvm.org/D112089
More information about the cfe-commits
mailing list