IR: fix compile time switch eval for enums
This commit is contained in:
parent
c64f9991d5
commit
a07d7ee53d
@ -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);
|
||||
|
@ -1,6 +1,6 @@
|
||||
const arch = switch (@compileVar("arch")) {
|
||||
x86_64 => @import("linux_x86_64.zig"),
|
||||
i386 => @import("linux_i386.zig"),
|
||||
Arch.x86_64 => @import("linux_x86_64.zig"),
|
||||
Arch.i386 => @import("linux_i386.zig"),
|
||||
else => @compileError("unsupported arch"),
|
||||
};
|
||||
const errno = @import("errno.zig");
|
||||
|
Loading…
x
Reference in New Issue
Block a user