diff options
| author | Jimmi Holst Christensen <jhc@liab.dk> | 2018-03-08 10:29:43 +0100 |
|---|---|---|
| committer | Jimmi Holst Christensen <jhc@liab.dk> | 2018-03-08 10:29:43 +0100 |
| commit | 689e241ff8a826ac03cca0e8d1c9f8628cc88756 (patch) | |
| tree | 8e09e8995ccec56f2f858d340b824b24733a578d /src/ir.cpp | |
| parent | 51b2f1b80b9bc43dc389044565cc3a72c174311e (diff) | |
| parent | 790aaeacaea88782987c4145bc7ae47a401563f1 (diff) | |
| download | zig-689e241ff8a826ac03cca0e8d1c9f8628cc88756.tar.gz zig-689e241ff8a826ac03cca0e8d1c9f8628cc88756.zip | |
Merge branch 'master' of github.com:zig-lang/zig
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index cdb8201b2b..811744e9d0 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -14137,6 +14137,14 @@ static IrInstruction *ir_analyze_union_tag(IrAnalyze *ira, IrInstruction *source buf_sprintf("expected enum or union type, found '%s'", buf_ptr(&value->value.type->name))); return ira->codegen->invalid_instruction; } + if (!value->value.type->data.unionation.have_explicit_tag_type && !source_instr->is_gen) { + ErrorMsg *msg = ir_add_error(ira, source_instr, buf_sprintf("union has no associated enum")); + if (value->value.type->data.unionation.decl_node != nullptr) { + add_error_note(ira->codegen, msg, value->value.type->data.unionation.decl_node, + buf_sprintf("declared here")); + } + return ira->codegen->invalid_instruction; + } TypeTableEntry *tag_type = value->value.type->data.unionation.tag_type; assert(tag_type->id == TypeTableEntryIdEnum); |
