diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-05-09 23:43:07 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-05-09 23:43:07 -0400 |
| commit | 6928badd850f9fcebdcc0b13287db2c81d2293c0 (patch) | |
| tree | 241e9cbce7646b6ca7a0b0287a9a76dd14a4f38e /src/analyze.cpp | |
| parent | ac4d55dec1e32ddef945bfa246eb78f20f31ec44 (diff) | |
| parent | bf21747a426887ed2ac866c9a9d317f64b22da79 (diff) | |
| download | zig-6928badd850f9fcebdcc0b13287db2c81d2293c0.tar.gz zig-6928badd850f9fcebdcc0b13287db2c81d2293c0.zip | |
Merge branch 'master' into pointer-reform
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 99712cbfaf..d6137a4286 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -2325,8 +2325,14 @@ static void resolve_enum_zero_bits(CodeGen *g, TypeTableEntry *enum_type) { HashMap<BigInt, AstNode *, bigint_hash, bigint_eql> occupied_tag_values = {}; occupied_tag_values.init(field_count); - TypeTableEntry *tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1); + TypeTableEntry *tag_int_type; + if (enum_type->data.enumeration.layout == ContainerLayoutExtern) { + tag_int_type = get_c_int_type(g, CIntTypeInt); + } else { + tag_int_type = get_smallest_unsigned_int_type(g, field_count - 1); + } + // TODO: Are extern enums allowed to have an init_arg_expr? if (decl_node->data.container_decl.init_arg_expr != nullptr) { TypeTableEntry *wanted_tag_int_type = analyze_type_expr(g, scope, decl_node->data.container_decl.init_arg_expr); if (type_is_invalid(wanted_tag_int_type)) { @@ -5926,8 +5932,8 @@ size_t type_id_len() { return array_length(all_type_ids); } -size_t type_id_index(TypeTableEntryId id) { - switch (id) { +size_t type_id_index(TypeTableEntry *entry) { + switch (entry->id) { case TypeTableEntryIdInvalid: zig_unreachable(); case TypeTableEntryIdMetaType: @@ -5947,6 +5953,8 @@ size_t type_id_index(TypeTableEntryId id) { case TypeTableEntryIdArray: return 7; case TypeTableEntryIdStruct: + if (entry->data.structure.is_slice) + return 25; return 8; case TypeTableEntryIdNumLitFloat: return 9; |
