wcc/cgen: route same-type tagged-cast return through the widener (wwstage align to cstage)

A same-type tagged cast return (`return x: u`, u == fnret) emitted tag=0
(a 2nd-variant value returned the wrong payload). Route it through the
widener (needswiden when N_CAST && ru1==fu1, beside S1's ru1!=fu1) which
peels the identity cast internally -> correct; same-type non-cast stays on
the passthrough. Byte-id-neutral. test/wcc/837.
This commit is contained in:
2026-06-09 19:07:57 +09:00
parent 08ccb734b2
commit 90452a8364
5 changed files with 251 additions and 0 deletions

View File

@@ -261,6 +261,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_tagged_arr_variant \
$(BIN)/test_nested_union_int_box \
$(BIN)/test_tagged_assignable_cluster \
$(BIN)/test_idcast_tagged_return \
$(BIN)/test_inferred_array_global \
$(BIN)/test_slice_str_global_arg \
$(BIN)/test_slice_str_global_zero \
@@ -744,6 +745,12 @@ $(BIN)/test_tagged_assignable_cluster: test/wcc/836_tagged_assignable_cluster.c
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
$(BIN)/test_idcast_tagged_return: test/wcc/837_idcast_tagged_return.c $(BIN)/ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
$(BIN)/test_inferred_array_global: test/wcc/833_inferred_array_global.c $(BIN)/ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \