wcc/check: #12+#106 reject overlong array-literal in return/call-arg/alias positions (wwstage)
An overlong array literal (more initializers than the declared length) is invalid -- cstage loud-rejects it everywhere -- but wwstage silently accepted (and truncated) it in several positions; #9 wired only the decl position. This folds the remaining three (one class: checkarrlitfits over-fill coverage), all wwstage-only reject-align: - #12a return fn f() [2]int = [1,2,3] -- silently accepted. - #12b call-arg g([1,2,3]) -- louded only late via cgen #271. - #106 alias type A=[2]int; let g: A = [1,2,3] -- silently truncated; checkarrlitfits bailed on the N_TNAME alias without chasing. Four inserts in check.ww: an alias-chase (resolvealias) at the top of checkarrlitfits (makes all callers alias-aware), the over-fill check wired into checkretassign (hoisted above the isassignable short-circuit) and desugarcallargs, and the alias-let-global guard made alias-aware. cstage unchanged (w6c md5 unchanged); reject-only, so no asm moves -- 990-997 8/8, no lib byte-id pin flips. A 5th position (tuple-element overlong) is a separate pre-existing hole, filed (#20). test/wcc/828 table-driven.
This commit is contained in:
7
Makefile
7
Makefile
@@ -256,6 +256,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
|
||||
$(BIN)/test_errfirst_union_try \
|
||||
$(BIN)/test_alias_tuple_coerce \
|
||||
$(BIN)/test_str_eq \
|
||||
$(BIN)/test_overlong_arrlit \
|
||||
$(BIN)/test_slice_str_global_zero \
|
||||
$(BIN)/test_slice_literal_global \
|
||||
$(BIN)/test_global_arr_elem_field \
|
||||
@@ -700,6 +701,12 @@ $(BIN)/test_str_eq: test/wcc/827_str_eq.c $(BIN)/ww \
|
||||
$(LIB)/libwwrt.a | $(BIN)
|
||||
$(CC) $(CFLAGS) -o $@ $<
|
||||
|
||||
$(BIN)/test_overlong_arrlit: test/wcc/828_overlong_arrlit.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_def_arr_infer_len: test/wcc/814_def_arr_infer_len.c $(BIN)/ww \
|
||||
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
|
||||
$(BIN)/ww_ww $(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
|
||||
|
||||
Reference in New Issue
Block a user