authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-19 17:35:19-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-08-19 17:35:19-04:00
log6bc520ab957e25f9ae6d0f4d8a8ad4b96e145ac3
tree81cdb2ae9662ac51d905eea0ccd40948ebc99c2a
parent24deb1a7fe955202335ed7540fa20a43ae6eca36
signaturelock-open Commit is signed but in an unrecognized format.

solve it a slightly different way

the error handling of result locations is a bit awkward but it should basically be the same everywhere

2 files changed, 7 insertions(+), 2 deletions(-)

src/ir.cpp+6-2
...@@ -24561,10 +24561,14 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst...@@ -24561,10 +24561,14 @@ static IrInstruction *ir_analyze_instruction_bit_cast_src(IrAnalyze *ira, IrInst
2456124561
24562 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,24562 IrInstruction *result_loc = ir_resolve_result(ira, &instruction->base,
24563 &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true);24563 &instruction->result_loc_bit_cast->base, operand->value.type, operand, false, false, true);
24564 if (result_loc != nullptr && !(type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))24564 if (result_loc != nullptr && (type_is_invalid(result_loc->value.type) || instr_is_unreachable(result_loc)))
24565 return result_loc;24565 return result_loc;
2456624566
24567 return instruction->result_loc_bit_cast->parent->gen_instruction;24567 if (instruction->result_loc_bit_cast->parent->gen_instruction != nullptr) {
24568 return instruction->result_loc_bit_cast->parent->gen_instruction;
24569 }
24570
24571 return result_loc;
24568}24572}
2456924573
24570static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira,24574static IrInstruction *ir_analyze_instruction_union_init_named_field(IrAnalyze *ira,
test/stage1/behavior/bitcast.zig+1
...@@ -129,4 +129,5 @@ test "implicit cast to error union by returning" {...@@ -129,4 +129,5 @@ test "implicit cast to error union by returning" {
129// issue #3010: compiler segfault129// issue #3010: compiler segfault
130test "bitcast literal [4]u8 param to u32" {130test "bitcast literal [4]u8 param to u32" {
131 const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 });131 const ip = @bitCast(u32, [_]u8{ 255, 255, 255, 255 });
132 expect(ip == maxInt(u32));
132}133}