selfhost/cmd/wcc: stamp typed-suffix N_INTLIT (#51, #52 precursor)

cstage cmd/wcc/check.c:694 cexpr N_INTLIT arm uses lookup_builtin
(n->tsuffix) with fall-through to ty_untyped_int. wwstage's exprtype
N_INTLIT arm at check.ww L1565 was unconditional untyped_int — a
symmetric-stage gap that left the last raw-str-typed reads of
TNAME.str / INTLIT.tsuffix alive in typenodeprimresolved /
exprprimresolved (the deferrals named at the end of A.6.3a, #45).

New arm: when e.tsuffix is non-empty, mktname+tinfofornode resolves
the builtin and stamps e.type_; on nil tinfo fall through to the
existing untyped_int path. Mirrors harec ref/harec/src/check.c
check_expr_literal routing typed ICONST through builtin_type_for_storage.

N_FLOATLIT at check.ww:1582 carries the same gap (cstage check.c:702
does the same lookup_builtin/untyped_float fall-through); filed as
#51b for a separate bisect-clean follow-up.

This is the additive stamp half; #52 collapses the two remaining
typenameisunsigned callers onto tinfo reads of the stamped type_.

Byte-identity (994/995) is the behavior gate; full make test green
at 133/133 confirms.
This commit is contained in:
2026-05-22 22:55:54 +09:00
parent e3237d1bcb
commit 1ce0f638bf
3 changed files with 36 additions and 0 deletions

View File

@@ -8633,6 +8633,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
// node.type_ as the SSoT; populating literals + idents closes the
// loop from the read side.
if (k == nkind.N_INTLIT) {
// Typed-int literal (`7u32`, `0i8`): tsuffix names a builtin
// primitive. Mirrors cstage cmd/wcc/check.c:694-701 cexpr's
// `lookup_builtin(n->tsuffix)`; falls through to untyped_int
// when the suffix doesn't resolve.
if (e.tsuffix.len > 0) {
let suf: *node = mktname(c, e.tsuffix);
let ti: *tinfo = tinfofornode(c, suf);
if (ti != nil) {
e.type_ = ti: *void;
return suf;
};
};
let tn: *node = mktname(c, "untyped_int");
e.type_ = tinfofornode(c, tn): *void;
return tn;

View File

@@ -1563,6 +1563,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
// node.type_ as the SSoT; populating literals + idents closes the
// loop from the read side.
if (k == nkind.N_INTLIT) {
// Typed-int literal (`7u32`, `0i8`): tsuffix names a builtin
// primitive. Mirrors cstage cmd/wcc/check.c:694-701 cexpr's
// `lookup_builtin(n->tsuffix)`; falls through to untyped_int
// when the suffix doesn't resolve.
if (e.tsuffix.len > 0) {
let suf: *node = mktname(c, e.tsuffix);
let ti: *tinfo = tinfofornode(c, suf);
if (ti != nil) {
e.type_ = ti: *void;
return suf;
};
};
let tn: *node = mktname(c, "untyped_int");
e.type_ = tinfofornode(c, tn): *void;
return tn;

View File

@@ -8633,6 +8633,18 @@ fn exprtype(c: *checker, e: *node, hint: *node) *node = {
// node.type_ as the SSoT; populating literals + idents closes the
// loop from the read side.
if (k == nkind.N_INTLIT) {
// Typed-int literal (`7u32`, `0i8`): tsuffix names a builtin
// primitive. Mirrors cstage cmd/wcc/check.c:694-701 cexpr's
// `lookup_builtin(n->tsuffix)`; falls through to untyped_int
// when the suffix doesn't resolve.
if (e.tsuffix.len > 0) {
let suf: *node = mktname(c, e.tsuffix);
let ti: *tinfo = tinfofornode(c, suf);
if (ti != nil) {
e.type_ = ti: *void;
return suf;
};
};
let tn: *node = mktname(c, "untyped_int");
e.type_ = tinfofornode(c, tn): *void;
return tn;