aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-08-29 14:36:42 +0100
committergingerBill <bill@gingerbill.org>2019-08-29 14:36:42 +0100
commitc89fc35e941275085332ba16b453432b5b7a5086 (patch)
tree6da1a49448aeb7d6751d41aa2ce6e19a1f6a4e6e /src/check_decl.cpp
parent614d209824f005aa11a399bbe1bbf2b3b9e76687 (diff)
Fix global variable initialization ordering
(related to #427)
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index cf3cb8e97..d87e6def0 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -791,7 +791,7 @@ void check_proc_decl(CheckerContext *ctx, Entity *e, DeclInfo *d) {
}
}
-void check_var_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init_expr) {
+void check_global_variable_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init_expr) {
GB_ASSERT(e->type == nullptr);
GB_ASSERT(e->kind == Entity_Variable);
@@ -805,6 +805,7 @@ void check_var_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init_ex
ac.init_expr_list_count = init_expr != nullptr ? 1 : 0;
DeclInfo *decl = decl_info_of_entity(e);
+ GB_ASSERT(decl == ctx->decl);
if (decl != nullptr) {
check_decl_attributes(ctx, decl->attributes, var_decl_attribute, &ac);
}
@@ -1051,7 +1052,7 @@ void check_entity_decl(CheckerContext *ctx, Entity *e, DeclInfo *d, Type *named_
switch (e->kind) {
case Entity_Variable:
- check_var_decl(&c, e, d->type_expr, d->init_expr);
+ check_global_variable_decl(&c, e, d->type_expr, d->init_expr);
break;
case Entity_Constant:
check_const_decl(&c, e, d->type_expr, d->init_expr, named_type);