lib/ww/lex: port the u64 overflow guard into parseint (#53)

wwstage parseint dropped the pre-multiply overflow guard the C twin
carries (cmd/wcc/lex.c:156, if (v > (u64)~0ULL / (u64)base)), so any
integer literal exceeding u64 was silently accepted mod 2^64 while
cstage loudly rejected with 'bad integer literal' — a rule-10 stage
divergence and a silent wrong constant. Port the guard before the
multiply-add; wwstage now rejects in lockstep with cstage.

lib/ww embeds into the w6c/wwdump combined.ww snapshots; both regen'd.
989_intoverflow_reject pins the reject-matrix on both driver twins.
This commit is contained in:
2026-06-13 10:32:56 +09:00
parent 8f370533bb
commit cf0789c897
5 changed files with 230 additions and 0 deletions

View File

@@ -249,6 +249,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_tagged_subset_reject \
$(BIN)/test_callarg_typecheck \
$(BIN)/test_catA_f2_reject \
$(BIN)/test_intoverflow_reject \
$(BIN)/test_idxarg_run \
$(BIN)/test_chainidx_run \
$(BIN)/test_tupfieldsize_run \
@@ -685,6 +686,17 @@ $(BIN)/test_catA_f2_reject: test/wcc/989_catA_f2_reject.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_intoverflow_reject (F14 #53): an integer literal that overflows u64
# must FAIL to build on BOTH driver twins (wwstage parseint dropped the C
# twin's overflow guard). Needs the full cstage + wwstage tool sets plus
# libwwrt for the control links.
$(BIN)/test_intoverflow_reject: test/wcc/989_intoverflow_reject.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_idxarg_run (F7-c2, #45/#46): an indexed slice/str element passed as
# a call arg must push its full multi-word header. Builds+runs each fixture
# on BOTH the cstage `ww` and wwstage `ww_ww` drivers (rule-10), so it needs