check: gate C-style ... to bodiless decls, both stages (#11)

A bodied fn with a bare C-style `...` was silently accepted by cstage
and SEGFAULTED wwstage (resolvefnbody walked a typeless `...` param).
Gate it: bare C-`...` is allowed only on bodiless decls (extern /
@symbol prototypes), the real FFI path; Hare-style `T...` is unaffected.

ww restricts C-`...` to bodiless decls pending vastart/vaarg/vaend
builtins (#16); harec permits bodied C-variadic fns (check.c:3656) -- a
documented divergence, reopened when #16 lands.

Test 852 runs both stages; its reject rows require the gate's diagnostic
(not merely a nonzero exit), so a crash can't pass them vacuously.
This commit is contained in:
2026-06-21 12:14:31 +09:00
parent c814856550
commit 1f1efb273a
4 changed files with 263 additions and 0 deletions

View File

@@ -3332,6 +3332,12 @@ check_file(Checker *c, Node *file)
break;
}
case N_FNDECL: {
/* ww restricts C-style ... to bodiless decls pending
* vastart/vaarg/vaend builtins (#16); harec permits bodied
* C-variadic fns (check.c:3656). */
if (d->body != NULL && d->type->variadic)
err(c, d->pos, "C-style variadic '...' "
"requires a bodiless declaration");
if (d->body == NULL) break; /* extern decl */
Scope *saved = c->cur;
c->cur = newscope(c->a, saved);