[clang] [Clang] Handle consteval expression in array bounds expressions (PR #66222)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 27 13:37:18 PDT 2023


================
@@ -221,6 +221,15 @@ ExprResult Parser::ParseConstantExpression() {
   return ParseConstantExpressionInExprEvalContext(NotTypeCast);
 }
 
+ExprResult Parser::ParseArrayBoundExpression() {
+  EnterExpressionEvaluationContext ConstantEvaluated(
+      Actions, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+  // If we parse the bound of a VLA... we parse a non-constant
+  // constant-expression!
+  Actions.ExprEvalContexts.back().InConditionallyConstantEvaluateContext = true;
----------------
erichkeane wrote:

In reality, I'd probably prefer something like; 

``` auto Expr = ExpressionEvaluationContext::CreateForVLA```

kind of thing (or perhaps a builder-pattern like below), but that is probably a sizable refactor for everything.  I think I can hold my nose here and be OK for now.

``` ExprEvalContext Eva(ThingsEverythingNeeds).ForVLA()```



https://github.com/llvm/llvm-project/pull/66222


More information about the cfe-commits mailing list