srctree

february cozzocrea parent 50457482 da506aaf
translate-c: Explicit cast bool from float fix

inlinesplit
src/translate_c.zig added: 20, removed: 2, total 18
@@ -2380,6 +2380,14 @@ fn transCCast(
});
}
if (cIsFloating(src_type) and !cIsFloating(dst_type)) {
// bool expression: floating val != 0
if (qualTypeIsBoolean(dst_type)) {
return Tag.not_equal.create(c.arena, .{
.lhs = expr,
.rhs = Tag.zero_literal.init(),
});
}
 
// @as(dest_type, @intFromFloat(val))
return Tag.as.create(c.arena, .{
.lhs = dst_node,
 
filename was Deleted added: 20, removed: 2, total 18
@@ -0,0 +1,10 @@
#include <stdbool.h>
 
int main() {
float f = 2.0f;
bool b = (bool) f;
return 0;
}
 
// run-translated-c
// c_frontends=aro,clang