diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 18:44:45 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-17 18:44:45 -0400 |
| commit | 6c71e9a54da068202794c309e895b3f9ccfeb161 (patch) | |
| tree | fe7c623b2cb84786fd1f84a605017279e05ceb6a /src/ir.cpp | |
| parent | cf9200b81594071d6378df2294da1c737c780c05 (diff) | |
| download | zig-6c71e9a54da068202794c309e895b3f9ccfeb161.tar.gz zig-6c71e9a54da068202794c309e895b3f9ccfeb161.zip | |
fix crash when bit shifting a u1
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index f4b727412e..e2bcbcffee 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -12070,6 +12070,12 @@ static ZigType *ir_analyze_bit_shift(IrAnalyze *ira, IrInstructionBinOp *bin_op_ ir_add_error(ira, &bin_op_instruction->base, buf_sprintf("LHS of shift must be an integer type, or RHS must be compile-time known")); return ira->codegen->builtin_types.entry_invalid; + } else if (instr_is_comptime(casted_op2) && bigint_cmp_zero(&casted_op2->value.data.x_bigint) == CmpEQ) { + IrInstruction *result = ir_build_cast(&ira->new_irb, bin_op_instruction->base.scope, + bin_op_instruction->base.source_node, op1->value.type, op1, CastOpNoop); + result->value.type = op1->value.type; + ir_link_new_instruction(result, &bin_op_instruction->base); + return result->value.type; } ir_build_bin_op_from(&ira->new_irb, &bin_op_instruction->base, op_id, |
