parse,check,type,wwi: @packed struct attribute, both stages (#51)
Hare/harec @packed struct layout: no inter-field or trailing padding, align =
max field align (NOT forced to 1) — matches harec type_store.c + types.c:621
(packed{u8,u64}=size 9/align 8). Parser consumes inline @packed (loud-rejects
unknown struct attrs, both stages); layout gates padding on !packed; cstage
type_eq enforces packed type-distinctness; the .wwi producer round-trips
"struct @packed {". wwstage sets slotsize=size for packed so its composite-ABI
copy matches cstage byte-for-byte. cstage identity is faithful; wwstage identity
rides the deferred #224 nominal-resolvealias arc (#108). Both stages byte-id;
447 tests pass.
This commit is contained in:
@@ -935,7 +935,11 @@ resolve_type(Checker *c, Node *n)
|
||||
if (!require_sized(c, ft, f->pos, "a struct field"))
|
||||
continue;
|
||||
if (ft->align > maxalign) maxalign = ft->align;
|
||||
off = (off + ft->align - 1) & ~(ft->align - 1);
|
||||
/* packed: no inter-field padding (harec
|
||||
* type_store.c:206-213); align still tracks the
|
||||
* max field align below. */
|
||||
if (!n->packed)
|
||||
off = (off + ft->align - 1) & ~(ft->align - 1);
|
||||
if (f->str != NULL) {
|
||||
/* regular named field */
|
||||
for (Tfield *e = head; e; e = e->next)
|
||||
@@ -985,8 +989,12 @@ resolve_type(Checker *c, Node *n)
|
||||
off = base + inner->size;
|
||||
}
|
||||
t->fields = head;
|
||||
t->packed = n->packed;
|
||||
t->align = maxalign;
|
||||
t->size = (off + maxalign - 1) & ~(maxalign - 1);
|
||||
/* packed: skip the trailing pad-to-align (harec
|
||||
* type_store.c:886 `!packed`); align value unchanged. */
|
||||
t->size = n->packed ? off
|
||||
: ((off + maxalign - 1) & ~(maxalign - 1));
|
||||
return t;
|
||||
}
|
||||
case N_TENUM: {
|
||||
|
||||
Reference in New Issue
Block a user