[clang] [Clang] Implement consteval blocks for C++26 (PR #188665)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 15 02:57:02 PDT 2026


================
@@ -1434,6 +1445,9 @@ ExprResult Parser::ParseLambdaExpressionAfterIntroducer(
       TrailingReturnTypeLoc = Range.getBegin();
       if (Range.getEnd().isValid())
         DeclEndLoc = Range.getEnd();
+    } else if (ConstevalBlockStart.isValid()) {
+      TrailingReturnType = ParsedType::make(Actions.Context.VoidTy);
+      TrailingReturnTypeLoc = ConstevalBlockStart;
----------------
cor3ntin wrote:

In fact, given the complexity of that function, I'd rather we do not reuse it for consteval blocks at all.

You should be able to have a much simpler parsing function 

that just
 - Parse `consteval`
 - Push a lambda scope
 - call ActOnLambdaExpressionAfterIntroducer (I wonder if we should encapulate that in a `act on consteval block start` for clarity)
 - add static / consteval
 - Call `AddTypeInfo`
 - set a BodyScope
 - Call ActOnStartOfLambdaDefinition
 - Call  ParseCompoundStatementBody

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


More information about the cfe-commits mailing list