Skip to content

Commit

Permalink
Fix undefined global enum variable
Browse files Browse the repository at this point in the history
  • Loading branch information
tyfkda committed Jan 14, 2024
1 parent d491670 commit 156b558
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/wcc/traverse.c
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,7 @@ uint32_t traverse_ast(Vector *decls, Vector *exports, uint32_t stack_size) {
// Global scope
for (int i = 0, len = global_scope->vars->len; i < len; ++i) {
VarInfo *varinfo = global_scope->vars->data[i];
if (varinfo->storage & VS_EXTERN || varinfo->type->kind == TY_FUNC ||
(varinfo->type->kind == TY_FIXNUM && varinfo->type->fixnum.kind == FX_ENUM))
if (varinfo->storage & (VS_EXTERN | VS_ENUM_MEMBER) || varinfo->type->kind == TY_FUNC)
continue;
register_gvar_info(varinfo->name, varinfo);
traverse_initializer(varinfo->global.init);
Expand Down
3 changes: 3 additions & 0 deletions tests/valtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -948,6 +948,9 @@ TEST(basic) {

enum Num num = Zero;
EXPECT_FALSE(num == One);

static enum Num num2 = Two;
EXPECT_TRUE(num2 == Two);
}

// empty block
Expand Down

0 comments on commit 156b558

Please sign in to comment.