diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp --- a/clang/lib/Parse/ParseDecl.cpp +++ b/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; diff --git a/clang/test/Interpreter/execute-stmts.cpp b/clang/test/Interpreter/execute-stmts.cpp --- a/clang/test/Interpreter/execute-stmts.cpp +++ b/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