aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp
index 0ce662570..847296eef 100644
--- a/src/check_decl.cpp
+++ b/src/check_decl.cpp
@@ -248,6 +248,33 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def)
named->Named.base = bt;
e->TypeName.is_type_alias = true;
}
+
+ // using decl
+ if (decl->is_using) {
+ // NOTE(bill): Must be an enum declaration
+ if (te->kind == Ast_EnumType) {
+ Scope *parent = ctx->scope->parent;
+ if (parent->flags&ScopeFlag_File) {
+ // NOTE(bill): Use package scope
+ parent = parent->parent;
+ }
+
+ Type *t = base_type(e->type);
+ GB_ASSERT(t->kind == Type_Enum);
+
+ for_array(i, t->Enum.fields) {
+ Entity *f = t->Enum.fields[i];
+ if (f->kind != Entity_Constant) {
+ continue;
+ }
+ String name = f->token.string;
+ if (is_blank_ident(name)) {
+ continue;
+ }
+ add_entity(ctx->checker, parent, nullptr, f);
+ }
+ }
+ }
}