[PATCH] D139798: [clang-repl] Support compound statement as a top-level statement.

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 17 01:09:49 PST 2023


This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG159073bc0a87: [clang-repl] Support compound statement as a top-level statement. (authored by v.g.vassilev).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D139798?vs=481945&id=498279#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139798/new/

https://reviews.llvm.org/D139798

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Interpreter/execute-stmts.cpp


Index: clang/test/Interpreter/execute-stmts.cpp
===================================================================
--- clang/test/Interpreter/execute-stmts.cpp
+++ clang/test/Interpreter/execute-stmts.cpp
@@ -34,5 +34,10 @@
 for (; i > 4; --i) printf("i = %d\n", i);
 // CHECK-NEXT: i = 5
 
+{++i;}
+
+for (; i > 4; --i) { printf("i = %d\n", i); };
+// CHECK-NEXT: i = 5
+
 int j = i; printf("j = %d\n", j);
 // CHECK-NEXT: j = 4
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5400,7 +5400,9 @@
   // 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;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139798.498279.patch
Type: text/x-patch
Size: 918 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230217/9078cc77/attachment.bin>


More information about the cfe-commits mailing list