selfhost+cstage+test: graduate *[]T indexing to slice-element type (#20)
Cstage and wwstage share the latent: check.c's N_INDEX bespoke TY_PTR-over-TY_SLICE clause peeled the slice in `*[]T[i]` and returned the element of the element, while wwstage's elemsizeof had no N_TSLICE arm for the post-N_TPTR-peel elem and fell to the 8B catch-all. Splitting leaves one stage broken on the exact `*[]T[i]` shape the new 754 sentinel asserts byte-identical between stages (rule 11). The companion 24B per-element copy emit is a separate codegen wedge already pinned inline at cmd/w6c/cgen.c:6518; out-of-scope here and noted in the fixture header.
This commit is contained in:
@@ -874,8 +874,14 @@ cexpr(Checker *c, Node *n)
|
||||
return n->type = u->sub;
|
||||
if (u && u->kind == TY_STR)
|
||||
return n->type = ty_u8;
|
||||
/* `*[N]T` auto-decays to `[N]T` indexing — drill into the
|
||||
* inner T so callers see the element type, matching C's
|
||||
* pointer-to-array semantics. `*[]T` does NOT auto-decay:
|
||||
* `p[i]` for `p: *[]T` yields `[]T` via the default `*U → U`
|
||||
* fall-through below (here U is `[]T`). Hare-faithful: a
|
||||
* pointer-to-slice is a 1D array of slices, not of T. */
|
||||
if (u && u->kind == TY_PTR && u->sub &&
|
||||
(u->sub->kind == TY_ARRAY || u->sub->kind == TY_SLICE))
|
||||
u->sub->kind == TY_ARRAY)
|
||||
return n->type = u->sub->sub;
|
||||
/* C-style pointer indexing: p[i] → *(p+i) */
|
||||
if (u && u->kind == TY_PTR && u->sub)
|
||||
|
||||
Reference in New Issue
Block a user