translate-c: Fix types on assign expression bool

This commit is contained in:
Evan Typanski
2023-01-28 11:53:38 -05:00
committed by Veikka Tuominen
parent 3c8d968194
commit 86ec26b1f0
2 changed files with 20 additions and 1 deletions

View File

@@ -3900,4 +3900,20 @@ pub fn addCases(cases: *tests.TranslateCContext) void {
\\pub const ZERO = @as(c_int, 0);
\\pub const WORLD = @as(c_int, 0o0000123);
});
cases.add("Assign expression from bool to int",
\\void foo(void) {
\\ int a;
\\ if (a = 1 > 0) {}
\\}
, &[_][]const u8{
\\pub export fn foo() void {
\\ var a: c_int = undefined;
\\ if ((blk: {
\\ const tmp = @boolToInt(@as(c_int, 1) > @as(c_int, 0));
\\ a = tmp;
\\ break :blk tmp;
\\ }) != 0) {}
\\}
});
}