From 159073bc0a873b9aa2bc559a8ceba970b049cda2 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Sun, 11 Dec 2022 21:08:30 +0000 Subject: [clang-repl] Support compound statement as a top-level statement. This patch teaches our incremental compilation infrastructure to push and pop a fake function scope making the Parser happy when parsing compound statements as part of a top-leve statement declaration. Differential revision: https://reviews.llvm.org/D139798 --- clang/lib/Parse/ParseDecl.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'clang/lib/Parse/ParseDecl.cpp') diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index d32f26b..6465d859 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -5400,7 +5400,9 @@ Parser::DeclGroupPtrTy Parser::ParseTopLevelStmtDecl() { // Parse a top-level-stmt. Parser::StmtVector Stmts; ParsedStmtContext SubStmtCtx = ParsedStmtContext(); + Actions.PushFunctionScope(); StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx); + Actions.PopFunctionScopeInfo(); if (!R.isUsable()) return nullptr; -- cgit v1.1