From aa542980cea146e05cf9bb5f1d792e1f092328ae Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 30 Aug 2018 19:14:10 +0100 Subject: Change memory layout of `map` to be 3 words smaller --- src/check_decl.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/check_decl.cpp') diff --git a/src/check_decl.cpp b/src/check_decl.cpp index 8569ee437..efcbbe1d6 100644 --- a/src/check_decl.cpp +++ b/src/check_decl.cpp @@ -217,11 +217,22 @@ Ast *remove_type_alias_clutter(Ast *node) { } } +isize total_attribute_count(DeclInfo *decl) { + isize attribute_count = 0; + for_array(i, decl->attributes) { + Ast *attr = decl->attributes[i]; + if (attr->kind != Ast_Attribute) continue; + attribute_count += attr->Attribute.elems.count; + } + return attribute_count; +} + + void check_type_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Type *def) { GB_ASSERT(e->type == nullptr); DeclInfo *decl = decl_info_of_entity(e); - if (decl != nullptr && decl->attributes.count > 0) { + if (decl != nullptr && total_attribute_count(decl) > 0) { error(decl->attributes[0], "Attributes are not allowed on type declarations"); } @@ -290,6 +301,8 @@ void override_entity_in_scope(Entity *original_entity, Entity *new_entity) { map_set(&found_scope->elements, hash_string(original_name), new_entity); } + + void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, Type *named_type) { GB_ASSERT(e->type == nullptr); GB_ASSERT(e->kind == Entity_Constant); @@ -380,7 +393,7 @@ void check_const_decl(CheckerContext *ctx, Entity *e, Ast *type_expr, Ast *init, DeclInfo *decl = decl_info_of_entity(e); - if (decl != nullptr && decl->attributes.count > 0) { + if (decl != nullptr && total_attribute_count(decl) > 0) { error(decl->attributes[0], "Attributes are not allowed on constant value declarations"); } } -- cgit v1.2.3