wcc/ww: tagged-union normalization at tinfofornode (never-drop, dedup, collapse, nullable fold)

wwstage computed tagged sizes/tags off the raw variant list — size()
folded wrong constants (size((*u8|void)) 16 vs 8, (i32|never) 16 vs 4)
and duplicate variants got divergent tag numbering vs cstage, while
ww's own cgen layout folded nullable but its size() didn't. Make
tinfofornode's N_TTAGGED arm the normalization SSoT mirroring cstage
resolve_type (check.c:801-882): never-drop, duplicate dedup via
structural typeeq, single-variant collapse, nullable fold on the
normalized pair; astsize/astalign delegate, and voidvariantindex reads
the normalized ti.params (cgen.c:900-911) so construct/match/void tag
readers agree. Corpus-neutral (zero-move on all combineds);
989_tagnorm_run pins the folds dual-stage, red-proven. Review items
#1/#3; residual #45 filed (AST-keyed nullable gate at global emit).
This commit is contained in:
2026-06-12 07:03:45 +09:00
parent d6052e0829
commit e0df2adf47
6 changed files with 666 additions and 201 deletions

View File

@@ -254,6 +254,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_gunsigned_run \
$(BIN)/test_taggedidx_run \
$(BIN)/test_fnptrcollide_run \
$(BIN)/test_tagnorm_run \
$(BIN)/test_arr_ptr_global \
$(BIN)/test_def_arr_infer_len \
$(BIN)/test_def_arr_len \
@@ -690,6 +691,16 @@ $(BIN)/test_taggedidx_run: test/wcc/989_taggedidx_run.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_tagnorm_run (F1, #1/#3): tagged-union type-set normalization (never-drop,
# dedup, single-collapse, nullable fold) must be symmetric — size()/align()
# fold + tag numbering. wwstage gated. See the test header.
$(BIN)/test_tagnorm_run: test/wcc/989_tagnorm_run.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_fnptrcollide_run (F7-c7, #14): a value ident whose leaf collides with
# a fn name must not be mis-folded into the fn's TEXT reloc. Build-must-fail
# on BOTH driver twins (rule-10); wwstage gated. See the test header.