diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-02 20:17:53 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-02 20:17:53 +0100 |
| commit | 206a3e093c19245e0f8ec7872b7cc36a3d266b55 (patch) | |
| tree | 0b62327720946dcc6f0c72bc4fd9237f72f48b55 /src/check_expr.c | |
| parent | 19bde275a3ea5f406b41d9b4895f8ba381684f25 (diff) | |
Remove check on array/slice/dynamic element size
Diffstat (limited to 'src/check_expr.c')
| -rw-r--r-- | src/check_expr.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/check_expr.c b/src/check_expr.c index 47ebae154..74cda433b 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -553,7 +553,7 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node) { struct_type->Record.field_count = field_count; struct_type->Record.names = make_names_field_for_record(c, c->context.scope); - if (!st->is_packed && !st->is_ordered) { + if (false && !st->is_packed && !st->is_ordered) { // NOTE(bill): Reorder fields for reduced size/performance Entity **reordered_fields = gb_alloc_array(c->allocator, Entity *, field_count); @@ -574,6 +574,10 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node) { struct_type->Record.fields = reordered_fields; } + { + // i64 size = type_size_of(c->allocator, struct_type); + } + type_set_offsets(c->allocator, struct_type); if (st->align != NULL) { @@ -657,8 +661,6 @@ void check_union_type(Checker *c, Type *union_type, AstNode *node) { union_type->Record.are_offsets_set = false; union_type->Record.is_ordered = true; - - for_array(i, ut->variants) { AstNode *variant = ut->variants.e[i]; if (variant->kind != AstNode_UnionField) { @@ -1601,21 +1603,25 @@ bool check_type_extra_internal(Checker *c, AstNode *e, Type **type, Type *named_ error_node(at->count, ".. can only be used in conjuction with compound literals"); count = 0; } +#if 0 i64 esz = type_size_of(c->allocator, elem); - if (esz <= 0) { + if (esz == 0) { gbString str = type_to_string(elem); error_node(at->elem, "Zero sized element type `%s` is not allowed", str); gb_string_free(str); } +#endif *type = make_type_array(c->allocator, elem, count); } else { Type *elem = check_type(c, at->elem); +#if 0 i64 esz = type_size_of(c->allocator, elem); - if (esz <= 0) { + if (esz == 0) { gbString str = type_to_string(elem); error_node(at->elem, "Zero sized element type `%s` is not allowed", str); gb_string_free(str); } +#endif *type = make_type_slice(c->allocator, elem); } return true; @@ -1624,11 +1630,13 @@ bool check_type_extra_internal(Checker *c, AstNode *e, Type **type, Type *named_ case_ast_node(dat, DynamicArrayType, e); Type *elem = check_type_extra(c, dat->elem, NULL); i64 esz = type_size_of(c->allocator, elem); - if (esz <= 0) { +#if 0 + if (esz == 0) { gbString str = type_to_string(elem); error_node(dat->elem, "Zero sized element type `%s` is not allowed", str); gb_string_free(str); } +#endif *type = make_type_dynamic_array(c->allocator, elem); return true; case_end; @@ -1735,7 +1743,7 @@ Type *check_type_extra(Checker *c, AstNode *e, Type *named_type) { type = t_invalid; } - if (is_type_named(type)) { + if (type->kind == Type_Named) { if (type->Named.base == NULL) { gbString name = type_to_string(type); error_node(e, "Invalid type definition of %s", name); |