w6c+wwstage: addr-of/slice struct array-field via dotbaseaddr (#252)
Taking &x.o[i] (address-of) or slicing x.o[lo:hi] / x.o[lo:] of a struct's [N]T-typed FIELD computed the field's VALUE as the base address (MOVL off(BP),AX) instead of its ADDRESS (LEAQ off(BP),AX) -> garbage pointer -> segfault. The index read/write path was fixed in #135; this is the unwired addr-of + slice sibling — both base-address paths fell to the generic cgexpr(base) auto-deref. Wire the #135 cg_dotbase_addr / dotbaseaddr helper into the addr-of N_INDEX complex-base arm and the N_SLICE base arm, symmetric on both stages (guarded if(!dotbase) cgexpr(base)). Extend the slice element stride (esz) and default-hi length to an N_DOT array-field base too, read from the field's element tinfo / array length via the type table (rule-13) — so non-u8 element slices scale correctly and s.obuf[lo:] gets the array's element count. cstage already derived default-hi via base->type (alen); only wwstage needed the N_DOT default-hi arm. cs==ww byte-identical on every shape. test/949_dotbase_addr_slice_run: 7 dual-stage rows (addr-of local + *struct param, explicit + default-hi u8 slice, non-u8 [4]i32 stride, bare-local control), run + cs==ww byte-id. Regen w6c/wwdump combined.ww.
This commit is contained in:
6
Makefile
6
Makefile
@@ -402,6 +402,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_deref_narrow_run \
|
||||
$(BIN)/test_idx_compound_run \
|
||||
$(BIN)/test_dotbase_arr_run \
|
||||
$(BIN)/test_dotbase_addr_slice_run \
|
||||
$(BIN)/test_structlit_arrfield_run \
|
||||
$(BIN)/test_continue_run \
|
||||
$(BIN)/test_callret_unsigned_arith_run \
|
||||
@@ -1594,6 +1595,11 @@ $(BIN)/test_dotbase_arr_run: test/wcc/949_dotbase_arr_run.c $(BIN)/ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_dotbase_addr_slice_run: test/wcc/949_dotbase_addr_slice_run.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_structlit_arrfield_run: test/wcc/949_structlit_arrfield_run.c \
|
||||
$(BIN)/ww $(BIN)/w6c $(BIN)/w6c_ww $(BIN)/w6a $(BIN)/w6l \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
|
||||
Reference in New Issue
Block a user