diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-05-02 21:16:09 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-05-02 21:16:09 +0100 |
| commit | cc6282a6e3463dd2b0192789fbd373a6d8f59a3d (patch) | |
| tree | bebc1e9f5cac3febb75d0ee2b6f8112660754171 /src | |
| parent | 206a3e093c19245e0f8ec7872b7cc36a3d266b55 (diff) | |
Fix alignment and size bug of enums; Remove #ordered and make the default #ordered.
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.c | 2 | ||||
| -rw-r--r-- | src/parser.c | 10 | ||||
| -rw-r--r-- | src/types.c | 5 |
3 files changed, 11 insertions, 6 deletions
diff --git a/src/check_expr.c b/src/check_expr.c index 74cda433b..eef6d1483 100644 --- a/src/check_expr.c +++ b/src/check_expr.c @@ -534,7 +534,7 @@ void check_struct_type(Checker *c, Type *struct_type, AstNode *node) { isize field_count = 0; for_array(field_index, st->fields) { - AstNode *field = st->fields.e[field_index]; + AstNode *field = st->fields.e[field_index]; switch (field->kind) { case_ast_node(f, Field, field); field_count += f->names.count; diff --git a/src/parser.c b/src/parser.c index cd8f65652..efa4acb83 100644 --- a/src/parser.c +++ b/src/parser.c @@ -2745,11 +2745,11 @@ AstNode *parse_type_or_ident(AstFile *f) { syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string)); } is_packed = true; - } else if (str_eq(tag.string, str_lit("ordered"))) { - if (is_ordered) { - syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string)); - } - is_ordered = true; + // } else if (str_eq(tag.string, str_lit("ordered"))) { + // if (is_ordered) { + // syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string)); + // } + // is_ordered = true; } else if (str_eq(tag.string, str_lit("align"))) { if (align) { syntax_error(tag, "Duplicate struct tag `#%.*s`", LIT(tag.string)); diff --git a/src/types.c b/src/types.c index 5c60f19b7..711a74456 100644 --- a/src/types.c +++ b/src/types.c @@ -1595,6 +1595,8 @@ i64 type_align_of_internal(gbAllocator allocator, Type *t, TypePath *path) { case Type_Record: { switch (t->Record.kind) { + case TypeRecord_Enum: + return type_align_of_internal(allocator, t->Record.enum_base_type, path); case TypeRecord_Struct: if (t->Record.custom_align > 0) { return gb_clamp(t->Record.custom_align, 1, build_context.max_align); @@ -1844,6 +1846,9 @@ i64 type_size_of_internal(gbAllocator allocator, Type *t, TypePath *path) { case Type_Record: { switch (t->Record.kind) { + case TypeRecord_Enum: + return type_size_of_internal(allocator, t->Record.enum_base_type, path); + case TypeRecord_Struct: { i64 count = t->Record.field_count; if (count == 0) { |