zig/test/behavior/byval_arg_var.zig
joachimschmidt557 d6e6162081
stage2 AArch64: unify callee-preserved regs on all targets
also enables many passing behavior tests
2022-12-27 21:17:52 +08:00

32 lines
639 B
Zig

const std = @import("std");
const builtin = @import("builtin");
var result: []const u8 = "wrong";
test "pass string literal byvalue to a generic var param" {
if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest;
if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
start();
blowUpStack(10);
try std.testing.expect(std.mem.eql(u8, result, "string literal"));
}
fn start() void {
foo("string literal");
}
fn foo(x: anytype) void {
bar(x);
}
fn bar(x: anytype) void {
result = x;
}
fn blowUpStack(x: u32) void {
if (x == 0) return;
blowUpStack(x - 1);
}