Skip to content
This repository was archived by the owner on Nov 26, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Translator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2677,7 +2677,7 @@ fn transShiftExpr(t: *Translator, scope: *Scope, bin: Node.Binary, op_id: ZigTag
// lhs >> @intCast(rh)
const lhs = try t.transExpr(scope, bin.lhs, .used);

const rhs = try t.transExprCoercing(scope, bin.rhs, .used);
const rhs = try t.transExpr(scope, bin.rhs, .used);
const rhs_casted = try ZigTag.int_cast.create(t.arena, rhs);

return t.createBinOpNode(op_id, lhs, rhs_casted);
Expand Down
2 changes: 1 addition & 1 deletion test/cases/translate/bitshift.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ int foo(void) {
// translate
//
// pub export fn foo() c_int {
// return (@as(c_int, 1) << @intCast(2)) >> @intCast(1);
// return (@as(c_int, 1) << @intCast(@as(c_int, 2))) >> @intCast(@as(c_int, 1));
// }
9 changes: 9 additions & 0 deletions test/cases/translate/bitshift_with_bitcast.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
unsigned int bit31() {
return 1u << (31);
}

// translate
//
// pub export fn bit31() c_uint {
// return @as(c_uint, 1) << @intCast(@as(c_uint, @bitCast(@as(c_int, @as(c_int, 31)))));
// }