aboutsummaryrefslogtreecommitdiff
path: root/src/check_decl.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-08-30 19:14:10 +0100
committergingerBill <bill@gingerbill.org>2018-08-30 19:14:10 +0100
commitaa542980cea146e05cf9bb5f1d792e1f092328ae (patch)
treeeea45538d6934f0c669a5bf218396d2ce6294098 /src/check_decl.cpp
parente0240c186f2939f39f2051c5123b8b75e5fdb184 (diff)
Change memory layout of `map` to be 3 words smaller
Diffstat (limited to 'src/check_decl.cpp')
-rw-r--r--src/check_decl.cpp17
1 files changed, 15 insertions, 2 deletions
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");
}
}