authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-14 18:25:14-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-05-14 18:25:14-04:00
logc08c222d5e8881631a4e3c56a9bda909c25e6c0b
tree772d599c4f7d9fd29671022f5b65acea8418248e
parentdf4f77024e93dc3b60dd1d76d64e3c5ffa5ebd84
signaturelock-open Commit is signed but in an unrecognized format.

fix regression on switch capture value for multiple cases


1 files changed, 10 insertions(+), 7 deletions(-)

src/ir.cpp+10-7
......@@ -6329,17 +6329,20 @@ static bool ir_gen_switch_prong_expr(IrBuilder *irb, Scope *scope, AstNode *swit
63296329 ZigVar *var = ir_create_var(irb, var_symbol_node, scope,
63306330 var_name, is_const, is_const, is_shadowable, var_is_comptime);
63316331 child_scope = var->child_scope;
6332 IrInstruction *var_ptr_value;
6333 if (prong_value != nullptr) {
6334 var_ptr_value = ir_build_switch_var(irb, scope, var_symbol_node, target_value_ptr, prong_value);
6335 } else {
6332 IrInstruction *var_value;
6333 if (out_switch_else_var != nullptr) {
63366334 IrInstructionSwitchElseVar *switch_else_var = ir_build_switch_else_var(irb, scope, var_symbol_node,
63376335 target_value_ptr);
63386336 *out_switch_else_var = switch_else_var;
6339 var_ptr_value = &switch_else_var->base;
6337 IrInstruction *var_ptr_value = &switch_else_var->base;
6338 var_value = var_is_ptr ? var_ptr_value : ir_build_load_ptr(irb, scope, var_symbol_node, var_ptr_value);
6339 } else if (prong_value != nullptr) {
6340 IrInstruction *var_ptr_value = ir_build_switch_var(irb, scope, var_symbol_node, target_value_ptr, prong_value);
6341 var_value = var_is_ptr ? var_ptr_value : ir_build_load_ptr(irb, scope, var_symbol_node, var_ptr_value);
6342 } else {
6343 var_value = var_is_ptr ? target_value_ptr : ir_build_load_ptr(irb, scope, var_symbol_node,
6344target_value_ptr);
63406345 }
6341 IrInstruction *var_value = var_is_ptr ?
6342 var_ptr_value : ir_build_load_ptr(irb, scope, var_symbol_node, var_ptr_value);
63436346 IrInstruction *var_type = nullptr; // infer the type
63446347 ir_build_var_decl_src(irb, scope, var_symbol_node, var, var_type, nullptr, var_value);
63456348 } else {