mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 05:44:20 +00:00
Sema: check for NaNs in cmp (#10760)
This commit is contained in:
parent
0893326e0e
commit
1b6a1e691f
2 changed files with 9 additions and 4 deletions
|
|
@ -15816,6 +15816,13 @@ fn cmpNumeric(
|
|||
if (lhs_val.isUndef() or rhs_val.isUndef()) {
|
||||
return sema.addConstUndef(Type.bool);
|
||||
}
|
||||
if (lhs_val.isNan() or rhs_val.isNan()) {
|
||||
if (op == std.math.CompareOperator.neq) {
|
||||
return Air.Inst.Ref.bool_true;
|
||||
} else {
|
||||
return Air.Inst.Ref.bool_false;
|
||||
}
|
||||
}
|
||||
if (Value.compareHetero(lhs_val, op, rhs_val)) {
|
||||
return Air.Inst.Ref.bool_true;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -979,18 +979,16 @@ test "vector integer addition" {
|
|||
}
|
||||
|
||||
test "NaN comparison" {
|
||||
if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
|
||||
|
||||
try testNanEqNan(f16);
|
||||
try testNanEqNan(f32);
|
||||
try testNanEqNan(f64);
|
||||
try testNanEqNan(f128);
|
||||
if (has_f80_rt) try testNanEqNan(f80);
|
||||
if (has_f80_rt and (builtin.zig_backend == .stage1)) try testNanEqNan(f80); // TODO
|
||||
comptime try testNanEqNan(f16);
|
||||
comptime try testNanEqNan(f32);
|
||||
comptime try testNanEqNan(f64);
|
||||
comptime try testNanEqNan(f128);
|
||||
// comptime try testNanEqNan(f80);
|
||||
// comptime try testNanEqNan(f80); // TODO
|
||||
}
|
||||
|
||||
fn testNanEqNan(comptime F: type) !void {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue