mirror of
https://github.com/ziglang/zig.git
synced 2026-01-20 14:25:16 +00:00
add behavior test for recently fixed wasm backend bug
Adds the corresponding behavior test for the fix in 320c4d68f5f40794ae31d5535de9c3a8ff5cb471.
This commit is contained in:
parent
d40b71a39f
commit
616f74ba20
@ -1248,3 +1248,32 @@ test "bitcasting a packed struct at comptime and using the result" {
|
||||
_ = Struct.bitcast(@as(u64, 0)).cannotReach();
|
||||
}
|
||||
}
|
||||
|
||||
test "2-byte packed struct argument in C calling convention" {
|
||||
if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest;
|
||||
if (builtin.zig_backend == .stage2_spirv64) return error.SkipZigTest;
|
||||
|
||||
const S = packed struct(u16) {
|
||||
x: u15 = 0,
|
||||
y: u1 = 0,
|
||||
|
||||
fn foo(s: @This()) callconv(.C) i32 {
|
||||
return s.x;
|
||||
}
|
||||
fn bar(s: @This()) !void {
|
||||
try expect(foo(s) == 1);
|
||||
}
|
||||
};
|
||||
{
|
||||
var s: S = .{};
|
||||
s.x += 1;
|
||||
try S.bar(s);
|
||||
}
|
||||
comptime {
|
||||
var s: S = .{};
|
||||
s.x += 1;
|
||||
try S.bar(s);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user