@@ -392,21 +392,6 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
392
392
Result, Result.getEndLoc ());
393
393
TLCD->setBody (Brace);
394
394
Entries.push_back (TLCD);
395
-
396
- // If the parsed stmt was a GuardStmt, push the VarDecls into the
397
- // Entries list, so that they can be found by unqual name lookup later.
398
- if (!IsTopLevel) {
399
- auto resultStmt = Result.dyn_cast <Stmt*>();
400
- if (auto guard = dyn_cast_or_null<GuardStmt>(resultStmt)) {
401
- for (const auto &elt : guard->getCond ()) {
402
- if (!elt.getPatternOrNull ()) continue ;
403
-
404
- elt.getPattern ()->forEachVariable ([&](VarDecl *VD) {
405
- Entries.push_back (VD);
406
- });
407
- }
408
- }
409
- }
410
395
}
411
396
} else if (Tok.is (tok::kw_init) && isa<ConstructorDecl>(CurDeclContext)) {
412
397
SourceLoc StartLoc = Tok.getLoc ();
@@ -422,15 +407,6 @@ ParserStatus Parser::parseBraceItems(SmallVectorImpl<ASTNode> &Entries,
422
407
if (ExprOrStmtStatus.isError ())
423
408
NeedParseErrorRecovery = true ;
424
409
diagnoseDiscardedClosure (*this , Result);
425
- if (ExprOrStmtStatus.isSuccess () && IsTopLevel) {
426
- // If this is a normal library, you can't have expressions or
427
- // statements outside at the top level.
428
- diagnose (Tok.getLoc (),
429
- Result.is <Stmt*>() ? diag::illegal_top_level_stmt
430
- : diag::illegal_top_level_expr);
431
- Result = ASTNode ();
432
- }
433
-
434
410
if (!Result.isNull ())
435
411
Entries.push_back (Result);
436
412
}
0 commit comments