| author | |
| committer | |
| log | be26c3bf4e4c6a7654ea68e6606c1167ef969a09 |
| tree | 7aa5e1e1f9795f7aa1d01ff970ea22e9dd901d00 |
| parent | ad9655db3a0e831f8e88bc902db7363547f9a12b |
Closes #53692 files changed, 12 insertions(+), 0 deletions(-)
src/stage1/ir.cpp+4| ... | ... | @@ -28880,6 +28880,10 @@ static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOv |
| 28880 | 28880 | if (type_is_invalid(casted_result_ptr->value->type)) |
| 28881 | 28881 | return ira->codegen->invalid_inst_gen; |
| 28882 | 28882 | |
| 28883 | // Don't write anything to the result pointer. | |
| 28884 | if (dest_type->data.integral.bit_count == 0) | |
| 28885 | return ir_const_bool(ira, &instruction->base.base, false); | |
| 28886 | ||
| 28883 | 28887 | if (instr_is_comptime(casted_op1) && |
| 28884 | 28888 | instr_is_comptime(casted_op2) && |
| 28885 | 28889 | instr_is_comptime(casted_result_ptr)) |
test/stage1/behavior/math.zig+8| ... | ... | @@ -109,6 +109,14 @@ test "@shlWithOverflow" { |
| 109 | 109 | expect(result == 0b1011111111111100); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | test "@*WithOverflow with u0 values" { | |
| 113 | var result: u0 = undefined; | |
| 114 | expect(!@addWithOverflow(u0, 0, 0, &result)); | |
| 115 | expect(!@subWithOverflow(u0, 0, 0, &result)); | |
| 116 | expect(!@mulWithOverflow(u0, 0, 0, &result)); | |
| 117 | expect(!@shlWithOverflow(u0, 0, 0, &result)); | |
| 118 | } | |
| 119 | ||
| 112 | 120 | test "@clz" { |
| 113 | 121 | testClz(); |
| 114 | 122 | comptime testClz(); |