mirror of
https://github.com/ziglang/zig.git
synced 2026-02-12 20:37:54 +00:00
parent
ad9655db3a
commit
be26c3bf4e
@ -28880,6 +28880,10 @@ static IrInstGen *ir_analyze_instruction_overflow_op(IrAnalyze *ira, IrInstSrcOv
|
||||
if (type_is_invalid(casted_result_ptr->value->type))
|
||||
return ira->codegen->invalid_inst_gen;
|
||||
|
||||
// Don't write anything to the result pointer.
|
||||
if (dest_type->data.integral.bit_count == 0)
|
||||
return ir_const_bool(ira, &instruction->base.base, false);
|
||||
|
||||
if (instr_is_comptime(casted_op1) &&
|
||||
instr_is_comptime(casted_op2) &&
|
||||
instr_is_comptime(casted_result_ptr))
|
||||
|
||||
@ -109,6 +109,14 @@ test "@shlWithOverflow" {
|
||||
expect(result == 0b1011111111111100);
|
||||
}
|
||||
|
||||
test "@*WithOverflow with u0 values" {
|
||||
var result: u0 = undefined;
|
||||
expect(!@addWithOverflow(u0, 0, 0, &result));
|
||||
expect(!@subWithOverflow(u0, 0, 0, &result));
|
||||
expect(!@mulWithOverflow(u0, 0, 0, &result));
|
||||
expect(!@shlWithOverflow(u0, 0, 0, &result));
|
||||
}
|
||||
|
||||
test "@clz" {
|
||||
testClz();
|
||||
comptime testClz();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user