diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-09-21 21:16:46 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-09-21 21:16:46 -0700 |
| commit | 0c70bb4fce8b0460f86ed218f54ba31b291f2bfb (patch) | |
| tree | 1e0ad8f9ea76b30e52753a2f25f5f1d18d25896d /src/stage1/analyze.cpp | |
| parent | afac5d28951cfd913851094649e8b9f2136694ca (diff) | |
| parent | 58ee5f4e61cd9b7a9ba65798e2214efa3753a733 (diff) | |
| download | zig-0c70bb4fce8b0460f86ed218f54ba31b291f2bfb.tar.gz zig-0c70bb4fce8b0460f86ed218f54ba31b291f2bfb.zip | |
Merge remote-tracking branch 'origin/master' into stage2-zig-cc
Diffstat (limited to 'src/stage1/analyze.cpp')
| -rw-r--r-- | src/stage1/analyze.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/stage1/analyze.cpp b/src/stage1/analyze.cpp index 6c6f198e7a..15c30350d7 100644 --- a/src/stage1/analyze.cpp +++ b/src/stage1/analyze.cpp @@ -3161,30 +3161,29 @@ static Error resolve_union_zero_bits(CodeGen *g, ZigType *union_type) { tag_type->data.enumeration.fields_by_name.init(field_count); tag_type->data.enumeration.decls_scope = union_type->data.unionation.decls_scope; } else if (enum_type_node != nullptr) { - ZigType *enum_type = analyze_type_expr(g, scope, enum_type_node); - if (type_is_invalid(enum_type)) { + tag_type = analyze_type_expr(g, scope, enum_type_node); + } else { + if (decl_node->type == NodeTypeContainerDecl) { + tag_type = nullptr; + } else { + tag_type = union_type->data.unionation.tag_type; + } + } + if (tag_type != nullptr) { + if (type_is_invalid(tag_type)) { union_type->data.unionation.resolve_status = ResolveStatusInvalid; return ErrorSemanticAnalyzeFail; } - if (enum_type->id != ZigTypeIdEnum) { + if (tag_type->id != ZigTypeIdEnum) { union_type->data.unionation.resolve_status = ResolveStatusInvalid; - add_node_error(g, enum_type_node, - buf_sprintf("expected enum tag type, found '%s'", buf_ptr(&enum_type->name))); + add_node_error(g, enum_type_node != nullptr ? enum_type_node : decl_node, + buf_sprintf("expected enum tag type, found '%s'", buf_ptr(&tag_type->name))); return ErrorSemanticAnalyzeFail; } - if ((err = type_resolve(g, enum_type, ResolveStatusAlignmentKnown))) { + if ((err = type_resolve(g, tag_type, ResolveStatusAlignmentKnown))) { assert(g->errors.length != 0); return err; } - tag_type = enum_type; - } else { - if (decl_node->type == NodeTypeContainerDecl) { - tag_type = nullptr; - } else { - tag_type = union_type->data.unionation.tag_type; - } - } - if (tag_type != nullptr) { covered_enum_fields = heap::c_allocator.allocate<bool>(tag_type->data.enumeration.src_field_count); } union_type->data.unionation.tag_type = tag_type; |
