authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-10-25 18:31:01+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-10-25 18:31:01+01:00
log4adf63aefc62efb301c27d9f6ec71f92f52c23ca
tree5fab2fe1de84f134dce1489802d269fcc4e29474
parent985b13934da0eea9e01db6232c958485e30b97ef
parent97e584a6b9786ad942e4c8db0ce5b3b948ddad7e
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #21796 from Rexicon226/var-args

fix callconv resolution for varargs

2 files changed, 17 insertions(+), 1 deletions(-)

src/Compilation.zig+1
...@@ -1962,6 +1962,7 @@ pub fn destroy(comp: *Compilation) void {...@@ -1962,6 +1962,7 @@ pub fn destroy(comp: *Compilation) void {
1962 comp.failed_win32_resources.deinit(gpa);1962 comp.failed_win32_resources.deinit(gpa);
19631963
1964 comp.link_diags.deinit();1964 comp.link_diags.deinit();
1965 comp.link_task_queue.deinit(gpa);
19651966
1966 comp.clearMiscFailures();1967 comp.clearMiscFailures();
19671968
src/Sema.zig+16-1
...@@ -26619,6 +26619,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -26619,6 +26619,7 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2661926619
26620 const pt = sema.pt;26620 const pt = sema.pt;
26621 const zcu = pt.zcu;26621 const zcu = pt.zcu;
26622 const ip = &zcu.intern_pool;
26622 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;26623 const inst_data = sema.code.instructions.items(.data)[@intFromEnum(inst)].pl_node;
26623 const extra = sema.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index);26624 const extra = sema.code.extraData(Zir.Inst.FuncFancy, inst_data.payload_index);
26624 const target = zcu.getTarget();26625 const target = zcu.getTarget();
...@@ -26789,7 +26790,21 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A...@@ -26789,7 +26790,21 @@ fn zirFuncFancy(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!A
2678926790
26790 const zir_decl = sema.code.getDeclaration(decl_inst.resolve(&zcu.intern_pool) orelse return error.AnalysisFail)[0];26791 const zir_decl = sema.code.getDeclaration(decl_inst.resolve(&zcu.intern_pool) orelse return error.AnalysisFail)[0];
26791 if (zir_decl.flags.is_export) {26792 if (zir_decl.flags.is_export) {
26792 break :cc .C;26793 break :cc target.cCallingConvention() orelse {
26794 // This target has no default C calling convention. We sometimes trigger a similar
26795 // error by trying to evaluate `std.builtin.CallingConvention.c`, so for consistency,
26796 // let's eval that now and just get the transitive error. (It's guaranteed to error
26797 // because it does the exact `cCallingConvention` call we just did.)
26798 const cc_type = try sema.getBuiltinType("CallingConvention");
26799 _ = try sema.namespaceLookupVal(
26800 block,
26801 LazySrcLoc.unneeded,
26802 cc_type.getNamespaceIndex(zcu),
26803 try ip.getOrPutString(sema.gpa, pt.tid, "c", .no_embedded_nulls),
26804 );
26805 // The above should have errored.
26806 @panic("std.builtin is corrupt");
26807 };
26793 }26808 }
26794 }26809 }
26795 break :cc .auto;26810 break :cc .auto;