diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-12-17 17:57:26 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-12-17 17:57:26 -0500 |
| commit | a07d7ee53d7695b7ca56ced0a4ba25de2532ccbc (patch) | |
| tree | 8ca58ad22f49e71f3b6a5561ba2af5d4075404cb /src | |
| parent | c64f9991d561ff9a8e3c4575e8149404784497d3 (diff) | |
| download | zig-a07d7ee53d7695b7ca56ced0a4ba25de2532ccbc.tar.gz zig-a07d7ee53d7695b7ca56ced0a4ba25de2532ccbc.zip | |
IR: fix compile time switch eval for enums
Diffstat (limited to 'src')
| -rw-r--r-- | src/ir.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index 4589af22db..5a1df80277 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7635,7 +7635,7 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, size_t case_count = switch_br_instruction->case_count; bool is_inline = ir_should_inline(&ira->new_irb) || switch_br_instruction->is_inline; - if (is_inline || target_value->static_value.special != ConstValSpecialRuntime) { + if (is_inline || instr_is_comptime(target_value)) { ConstExprValue *target_val = ir_resolve_const(ira, target_value); if (!target_val) return ir_unreach_error(ira); @@ -7646,6 +7646,12 @@ static TypeTableEntry *ir_analyze_instruction_switch_br(IrAnalyze *ira, if (case_value->type_entry->id == TypeTableEntryIdInvalid) return ir_unreach_error(ira); + if (case_value->type_entry->id == TypeTableEntryIdEnum) { + case_value = ir_analyze_enum_tag(ira, &switch_br_instruction->base, case_value); + if (case_value->type_entry->id == TypeTableEntryIdInvalid) + return ir_unreach_error(ira); + } + IrInstruction *casted_case_value = ir_implicit_cast(ira, case_value, target_value->type_entry); if (casted_case_value->type_entry->id == TypeTableEntryIdInvalid) return ir_unreach_error(ira); |
