From 88634f0481fb1bd78f8d018b76cab6590691c8a9 Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Tue, 29 Dec 2020 12:58:47 +0100 Subject: stage1: Allow variable capture for multi-prong switch arms Handle the multi-prong case as we do with range cases. Closes #7188 --- src/stage1/ir.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp index d3ed3cfaab..edda765ff9 100644 --- a/src/stage1/ir.cpp +++ b/src/stage1/ir.cpp @@ -24207,6 +24207,8 @@ static IrInstGen *ir_analyze_instruction_switch_var(IrAnalyze *ira, IrInstSrcSwi ref_type->data.pointer.allow_zero); return ir_analyze_ptr_cast(ira, &instruction->base.base, target_value_ptr, &instruction->target_value_ptr->base, new_target_value_ptr_type, &instruction->base.base, false, false); + } else if (instruction->prongs_len > 1) { + return target_value_ptr; } else { ir_add_error(ira, &instruction->base.base, buf_sprintf("switch on type '%s' provides no expression parameter", buf_ptr(&target_type->name))); -- cgit v1.2.3