diff --git a/selfhost/cmd/w6c/main.combined.ww b/selfhost/cmd/w6c/main.combined.ww index ac20e233..7441f933 100644 --- a/selfhost/cmd/w6c/main.combined.ww +++ b/selfhost/cmd/w6c/main.combined.ww @@ -21659,6 +21659,19 @@ fn cgcall(c: *cgen, n: *node) void = { isfnptrcall = true; }; }; + // #181-cgen: a non-named callee (`(*f)(...)` → N_UN TK_STAR, + // or any other expression-valued fn) is an indirect call. + // cgexpr the callee into AX; CALL AX. Mirrors cstage's + // default-fallthrough at cmd/w6c/cgen.c:5918-5921 which + // catches every callee shape that isn't a bare-IDENT module + // fn or N_DOT module-qualified call. Pre-fix wwstage emitted + // `CALL (SB)` (empty symbol) for the N_UN-callee shape — the + // IDENT/DOT name-emit branches missed and isfnptrcall stayed + // false. + if (callee.kind != nkind.N_IDENT + && callee.kind != nkind.N_DOT) { + isfnptrcall = true; + }; if (callee.kind == nkind.N_DOT) { let base: *node = callee.lhs; let fld: str = callee.str; diff --git a/selfhost/cmd/wcc/cgenexpr.ww b/selfhost/cmd/wcc/cgenexpr.ww index 956dae18..9fdc650d 100644 --- a/selfhost/cmd/wcc/cgenexpr.ww +++ b/selfhost/cmd/wcc/cgenexpr.ww @@ -4099,6 +4099,19 @@ fn cgcall(c: *cgen, n: *node) void = { isfnptrcall = true; }; }; + // #181-cgen: a non-named callee (`(*f)(...)` → N_UN TK_STAR, + // or any other expression-valued fn) is an indirect call. + // cgexpr the callee into AX; CALL AX. Mirrors cstage's + // default-fallthrough at cmd/w6c/cgen.c:5918-5921 which + // catches every callee shape that isn't a bare-IDENT module + // fn or N_DOT module-qualified call. Pre-fix wwstage emitted + // `CALL (SB)` (empty symbol) for the N_UN-callee shape — the + // IDENT/DOT name-emit branches missed and isfnptrcall stayed + // false. + if (callee.kind != nkind.N_IDENT + && callee.kind != nkind.N_DOT) { + isfnptrcall = true; + }; if (callee.kind == nkind.N_DOT) { let base: *node = callee.lhs; let fld: str = callee.str; diff --git a/selfhost/cmd/wwdump/main.combined.ww b/selfhost/cmd/wwdump/main.combined.ww index b60f8818..6dc73499 100644 --- a/selfhost/cmd/wwdump/main.combined.ww +++ b/selfhost/cmd/wwdump/main.combined.ww @@ -21659,6 +21659,19 @@ fn cgcall(c: *cgen, n: *node) void = { isfnptrcall = true; }; }; + // #181-cgen: a non-named callee (`(*f)(...)` → N_UN TK_STAR, + // or any other expression-valued fn) is an indirect call. + // cgexpr the callee into AX; CALL AX. Mirrors cstage's + // default-fallthrough at cmd/w6c/cgen.c:5918-5921 which + // catches every callee shape that isn't a bare-IDENT module + // fn or N_DOT module-qualified call. Pre-fix wwstage emitted + // `CALL (SB)` (empty symbol) for the N_UN-callee shape — the + // IDENT/DOT name-emit branches missed and isfnptrcall stayed + // false. + if (callee.kind != nkind.N_IDENT + && callee.kind != nkind.N_DOT) { + isfnptrcall = true; + }; if (callee.kind == nkind.N_DOT) { let base: *node = callee.lhs; let fld: str = callee.str;