From 40a50f5e2cd4900d2b3d13b353b18a8b6ae052af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Fri, 9 Oct 2026 08:46:20 +0200 Subject: [PATCH] test: move issue_12706 from test-standalone to test-c-abi --- test/c_abi/cfuncs.c | 11 ++++++++++ test/c_abi/main.zig | 11 ++++++++++ test/standalone/build.zig.zon | 3 --- test/standalone/issue_12706/build.zig | 30 --------------------------- test/standalone/issue_12706/main.zig | 12 ----------- test/standalone/issue_12706/test.c | 11 ---------- 6 files changed, 22 insertions(+), 56 deletions(-) delete mode 100644 test/standalone/issue_12706/build.zig delete mode 100644 test/standalone/issue_12706/main.zig delete mode 100644 test/standalone/issue_12706/test.c diff --git a/test/c_abi/cfuncs.c b/test/c_abi/cfuncs.c index cce4f0d77497f2c6579fcd25eb0a6028dc2b1064..66e682571ecde322efbeca5617d89cc0904ab0d6 100644 --- a/test/c_abi/cfuncs.c +++ b/test/c_abi/cfuncs.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include #include @@ -16775,6 +16776,16 @@ void c_x86_64_sysv_uint_int_uint_int(unsigned a, int b, unsigned c, int d) { assert_or_panic(d == -4); } +void c_varargs_fn_ptr(int n, ...) { + assert_or_panic(n == 2); + va_list ap; + va_start(ap, n); + void (*fn_ptr)(int) = va_arg(ap, void (*)(int)); + int arg = va_arg(ap, int); + va_end(ap); + fn_ptr(arg); +} + void c_win64_varargs_u64_f64_u64_f64(uint64_t a, double b, uint64_t c, double d) { assert_or_panic(a == UINT64_C(0x3ff0000000000000)); assert_or_panic(b == 2.0); diff --git a/test/c_abi/main.zig b/test/c_abi/main.zig index e7b98a181148e9aecfe3aeb775e8e3f62c15f036..d0022d01babcc7d9fae9d5d6a987f3092c83eadf 100644 --- a/test/c_abi/main.zig +++ b/test/c_abi/main.zig @@ -18009,6 +18009,17 @@ test "x86_64 sysv args" { c_x86_64_sysv_uint_int_uint_int(1, -2, 3, -4); } +extern fn c_varargs_fn_ptr(n: c_int, ...) void; + +fn zigVaCb(x: c_int) callconv(.c) void { + expect(x == 123) catch @panic("test failure: zigVaCb"); +} + +test "function pointer through varargs" { + // Bare function (not `&`), as in the original #12706 repro. + c_varargs_fn_ptr(2, zigVaCb, @as(c_int, 123)); +} + extern fn c_win64_varargs_u64_f64_u64_f64(...) void; extern fn c_win64_varargs_f64_u64_f64_u64(...) void; diff --git a/test/standalone/build.zig.zon b/test/standalone/build.zig.zon index 4c4961ccb991405e08aae11733a09cf9ca7e467f..9fd1de096b937d0b3cc0315228bc5fbfae8126c7 100644 --- a/test/standalone/build.zig.zon +++ b/test/standalone/build.zig.zon @@ -126,9 +126,6 @@ .c_embed_path = .{ .path = "c_embed_path", }, - .issue_12706 = .{ - .path = "issue_12706", - }, .coff_dwarf = .{ .path = "coff_dwarf", }, diff --git a/test/standalone/issue_12706/build.zig b/test/standalone/issue_12706/build.zig deleted file mode 100644 index e2b4d4fe2bf61750bd7e1435237385c502cde0b4..0000000000000000000000000000000000000000 --- a/test/standalone/issue_12706/build.zig +++ /dev/null @@ -1,30 +0,0 @@ -const std = @import("std"); -const builtin = @import("builtin"); - -pub fn build(b: *std.Build) void { - const test_step = b.step("test", "Test it"); - b.default_step = test_step; - - const optimize: std.builtin.Optimize = .debug; - const target = b.graph.host; - - const exe = b.addExecutable(.{ - .name = "main", - .root_module = b.createModule(.{ - .root_source_file = b.path("main.zig"), - .optimize = optimize, - .target = target, - }), - }); - - const c_sources = [_][]const u8{ - "test.c", - }; - exe.root_module.addCSourceFiles(.{ .files = &c_sources }); - exe.root_module.link_libc = true; - - const run_cmd = b.addRunArtifact(exe); - run_cmd.expectExitCode(0); - run_cmd.skip_foreign_checks = true; - test_step.dependOn(&run_cmd.step); -} diff --git a/test/standalone/issue_12706/main.zig b/test/standalone/issue_12706/main.zig deleted file mode 100644 index dc402ab92f80be8fae8a884c8c7b6b9452d57272..0000000000000000000000000000000000000000 --- a/test/standalone/issue_12706/main.zig +++ /dev/null @@ -1,12 +0,0 @@ -const std = @import("std"); -extern fn testFnPtr(n: c_int, ...) void; - -const val: c_int = 123; - -fn func(a: c_int) callconv(.c) void { - std.debug.assert(a == val); -} - -pub fn main() void { - testFnPtr(2, func, val); -} diff --git a/test/standalone/issue_12706/test.c b/test/standalone/issue_12706/test.c deleted file mode 100644 index 30b5c6269778dbf0ea000e2f9a65cb0b5ce0f67b..0000000000000000000000000000000000000000 --- a/test/standalone/issue_12706/test.c +++ /dev/null @@ -1,11 +0,0 @@ -#include - -void testFnPtr(int n, ...) { - va_list ap; - va_start(ap, n); - - void (*fnPtr)(int) = va_arg(ap, void (*)(int)); - int arg = va_arg(ap, int); - fnPtr(arg); - va_end(ap); -} \ No newline at end of file -- 2.54.0