diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2017-12-04 00:32:12 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2017-12-04 00:32:12 -0500 |
| commit | fce435db269162774106ce7e6ddf70871d5eeb49 (patch) | |
| tree | 802b598efbacef024bada19b17aec4c40cf11be9 /src/ir.cpp | |
| parent | 5a8367e8924e809b1390796eb656633ea5e34a86 (diff) | |
| download | zig-fce435db269162774106ce7e6ddf70871d5eeb49.tar.gz zig-fce435db269162774106ce7e6ddf70871d5eeb49.zip | |
fix abi alignment of union-enums not counting tag type
add more tests for unions
See #618
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index e70340b300..d784974ae8 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -12970,10 +12970,13 @@ static TypeTableEntry *ir_analyze_instruction_switch_target(IrAnalyze *ira, ir_build_load_ptr_from(&ira->new_irb, &switch_target_instruction->base, target_value_ptr); return target_type; case TypeTableEntryIdUnion: { - if (target_type->data.unionation.gen_tag_index == SIZE_MAX) { + AstNode *decl_node = target_type->data.unionation.decl_node; + if (!decl_node->data.container_decl.auto_enum && + decl_node->data.container_decl.init_arg_expr == nullptr) + { ErrorMsg *msg = ir_add_error(ira, target_value_ptr, buf_sprintf("switch on union which has no attached enum")); - add_error_note(ira->codegen, msg, target_type->data.unionation.decl_node, + add_error_note(ira->codegen, msg, decl_node, buf_sprintf("union declared here")); return ira->codegen->builtin_types.entry_invalid; } |
