Fix global variable initialization ordering

(related to #427)
This commit is contained in:
gingerBill
2019-08-29 14:36:42 +01:00
parent 614d209824
commit c89fc35e94
5 changed files with 47 additions and 39 deletions
+6 -1
View File
@@ -1735,7 +1735,12 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) {
}
for (isize i = 0; i < entity_count; i++) {
add_entity(ctx->checker, ctx->scope, entities[i]->identifier, entities[i]);
Entity *e = entities[i];
DeclInfo *d = decl_info_of_entity(e);
GB_ASSERT(d == nullptr);
add_entity(ctx->checker, ctx->scope, e->identifier, e);
d = make_decl_info(ctx->allocator, ctx->scope, ctx->decl);
add_entity_and_decl_info(ctx, e->identifier, e, d);
}
check_stmt(ctx, rs->body, new_flags);