diff options
| author | gingerBill <bill@gingerbill.org> | 2020-05-02 18:45:57 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2020-05-02 18:45:57 +0100 |
| commit | e27f5796d61aa1e1dbd4b2d52e9f580fd24d3fc2 (patch) | |
| tree | cfd4d3ccf48628950525cf55ae618400ae0e2543 /src/check_decl.cpp | |
| parent | ba4363d67832b7f192492e1354b273296cc0c755 (diff) | |
Add experimental atom op tables for llvm-backend
Diffstat (limited to 'src/check_decl.cpp')
| -rw-r--r-- | src/check_decl.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/check_decl.cpp b/src/check_decl.cpp index dd2432eb9..809ccbc9b 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -256,9 +256,6 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) GB_ASSERT(e->type == nullptr); DeclInfo *decl = decl_info_of_entity(e); - if (decl != nullptr) { - check_decl_attributes(ctx, decl->attributes, const_decl_attribute, nullptr); - } bool is_distinct = is_type_distinct(init_expr); Ast *te = remove_type_alias_clutter(init_expr); @@ -280,6 +277,10 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) error(init_expr, "'distinct' cannot be applied to 'typeid'"); is_distinct = false; } + if (is_distinct && is_type_any(e->type)) { + error(init_expr, "'distinct' cannot be applied to 'any'"); + is_distinct = false; + } if (!is_distinct) { e->type = bt; named->Named.base = bt; @@ -298,6 +299,23 @@ void check_type_decl(CheckerContext *ctx, Entity *e, Ast *init_expr, Type *def) } } + if (decl != nullptr) { + AttributeContext ac = {}; + check_decl_attributes(ctx, decl->attributes, type_decl_attribute, &ac); + if (ac.atom_op_table != nullptr) { + Type *bt = base_type(e->type); + switch (bt->kind) { + case Type_Struct: + bt->Struct.atom_op_table = ac.atom_op_table; + break; + default: + error(e->token, "Only struct types can have custom atom operations"); + gb_free(heap_allocator(), ac.atom_op_table); + break; + } + } + } + // using decl if (decl->is_using) { |