authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-17 18:44:45-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-17 18:44:45-04:00
log6c71e9a54da068202794c309e895b3f9ccfeb161
treefe7c623b2cb84786fd1f84a605017279e05ceb6a
parentcf9200b81594071d6378df2294da1c737c780c05
signaturelock-open Commit is signed but in an unrecognized format.

fix crash when bit shifting a u1


2 files changed, 11 insertions(+), 0 deletions(-)

src/ir.cpp+6
...@@ -12070,6 +12070,12 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_...@@ -12070,6 +12070,12 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_
12070 ir_add_error(ira, &bin_op_instruction->base,12070 ir_add_error(ira, &bin_op_instruction->base,
12071 buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known"));12071 buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known"));
12072 return ira->codegen->builtin_types.entry_invalid;12072 return ira->codegen->builtin_types.entry_invalid;
12073 } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value.data.x_bigint) == CmpEQ) {
12074 IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope,
12075 bin_op_instruction->base.source_node, op1->value.type, op1, CastOpNoop);
12076 result->value.type = op1->value.type;
12077 ir_link_new_instruction(result, &bin_op_instruction->base);
12078 return result->value.type;
12073 }12079 }
1207412080
12075 ir_build_bin_op_from(&ira->new_irb, &bin_op_instruction->base, op_id,12081 ir_build_bin_op_from(&ira->new_irb, &bin_op_instruction->base, op_id,
test/cases/eval.zig+5
...@@ -688,3 +688,8 @@ test "zero extend from u0 to u1" {...@@ -688,3 +688,8 @@ test "zero extend from u0 to u1" {
688 var zero_u1: u1 = zero_u0;688 var zero_u1: u1 = zero_u0;
689 assert(zero_u1 == 0);689 assert(zero_u1 == 0);
690}690}
691
692test "bit shift a u1" {
693 var x: u1 = 1;
694 var y = x << 0;
695}