Skip to content

Commit 39d0f4a

Browse files
fixup! Try to fix #83028
Add TopLevelStmtDecl to outer DeclContext (and push new scopes afterwards)
1 parent fdddae5 commit 39d0f4a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20448,17 +20448,18 @@ Decl *Sema::ActOnFileScopeAsmDecl(Expr *expr,
2044820448

2044920449
TopLevelStmtDecl *Sema::ActOnStartTopLevelStmtDecl(Scope *S) {
2045020450
auto *New = TopLevelStmtDecl::Create(Context, /*Statement=*/nullptr);
20451+
CurContext->addDecl(New);
20452+
PushDeclContext(S, New);
2045120453
PushFunctionScope();
2045220454
PushCompoundScope(false);
20453-
PushDeclContext(S, New);
2045420455
return New;
2045520456
}
2045620457

2045720458
void Sema::ActOnFinishTopLevelStmtDecl(TopLevelStmtDecl *D, Stmt *Statement) {
2045820459
D->setStmt(Statement);
20459-
PopDeclContext();
2046020460
PopCompoundScope();
2046120461
PopFunctionScopeInfo();
20462+
PopDeclContext();
2046220463
}
2046320464

2046420465
void Sema::ActOnPragmaRedefineExtname(IdentifierInfo* Name,

0 commit comments

Comments
 (0)