diff options
| author | Vexu <git@vexu.eu> | 2019-12-15 00:05:13 +0200 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-12-15 19:28:53 -0500 |
| commit | 0f38410ea6f60ce9cebf373069d4abfcac0e77e6 (patch) | |
| tree | a57673939888845bd3eb1553da5d6a23342e0e7f /src/ir.cpp | |
| parent | 59de23dfa010c5556f79fbb8b4c637c8d150fd88 (diff) | |
| download | zig-0f38410ea6f60ce9cebf373069d4abfcac0e77e6.tar.gz zig-0f38410ea6f60ce9cebf373069d4abfcac0e77e6.zip | |
improve extern enum
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 52f3126428..1b3af10bba 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -12728,7 +12728,7 @@ static IrInstruction *ir_analyze_int_to_enum(IrAnalyze *ira, IrInstruction *sour return ira->codegen->invalid_instruction; TypeEnumField *field = find_enum_field_by_tag(wanted_type, &val->data.x_bigint); - if (field == nullptr) { + if (field == nullptr && wanted_type->data.enumeration.layout != ContainerLayoutExtern) { Buf *val_buf = buf_alloc(); bigint_append_buf(val_buf, &val->data.x_bigint, 10); ErrorMsg *msg = ir_add_error(ira, source_instr, @@ -25791,6 +25791,10 @@ static IrInstruction *ir_analyze_instruction_check_switch_prongs(IrAnalyze *ira, } } if (!instruction->have_else_prong) { + if (switch_type->data.enumeration.layout == ContainerLayoutExtern) { + ir_add_error(ira, &instruction->base, + buf_sprintf("switch on an extern enum must have an else prong")); + } for (uint32_t i = 0; i < switch_type->data.enumeration.src_field_count; i += 1) { TypeEnumField *enum_field = &switch_type->data.enumeration.fields[i]; |
