wcc: structlit repeat-fill dim off the stamped tinfo (rule 13)
cgstructlitfill's `...` total read only an N_INTLIT dim node, so a def-dimensioned [N]T struct field under-filled: elements 1..N-1 kept the zero-fill, silently, wwstage only (cstage and the tn twin read the stamped array length). Read tichase(fi.tnode.type_).alen first; the surface node stays as the fallback for unstamped shapes.
This commit is contained in:
@@ -1,13 +1,13 @@
|
|||||||
package wwfixture;
|
package wwfixture;
|
||||||
|
|
||||||
def protocolversion: i32 = 1;
|
def protocolversion: i32 = 1;
|
||||||
def corpuscount: i32 = 1749;
|
def corpuscount: i32 = 1750;
|
||||||
def errorcount: i32 = 349;
|
def errorcount: i32 = 349;
|
||||||
def compilecount: i32 = 21;
|
def compilecount: i32 = 21;
|
||||||
def runcount: i32 = 209;
|
def runcount: i32 = 209;
|
||||||
def runexitcount: i32 = 1170;
|
def runexitcount: i32 = 1171;
|
||||||
def nativecount: i32 = 3498;
|
def nativecount: i32 = 3500;
|
||||||
def corpushash: str = "616b3e7f4fca31cb99409c58a29ac73623c997967ddd57651a1370c2c2e2be6a";
|
def corpushash: str = "d52fa0df91c89bf51bca70045a2dbf39d5012ac03bf687e231240dc1c5b3fc53";
|
||||||
|
|
||||||
type directive = enum i32 {
|
type directive = enum i32 {
|
||||||
ERROR = 0,
|
ERROR = 0,
|
||||||
|
|||||||
@@ -5937,11 +5937,18 @@ fn cgstructlitfill(c: *cgen, si: *structinfo, lit: *syntax.node,
|
|||||||
};
|
};
|
||||||
if (repeat) {
|
if (repeat) {
|
||||||
let total: i32 = idx;
|
let total: i32 = idx;
|
||||||
if (fi.tnode.rhs != nil) {
|
// rule 13: dim off the STAMPED array tinfo, not
|
||||||
|
// the surface node — an N_INTLIT-only read left a
|
||||||
|
// def-dimensioned [N]T field under-filled (ww-only
|
||||||
|
// silent; cstage + the tn twin read stamped alen).
|
||||||
|
let ftfill: *syntax.tinfo = tichase(fi.tnode.type_: *syntax.tinfo);
|
||||||
|
if (ftfill != nil && ftfill.kind == syntax.tykind.TY_ARRAY) {
|
||||||
|
total = ftfill.alen: i32;
|
||||||
|
} else { if (fi.tnode.rhs != nil) {
|
||||||
if (fi.tnode.rhs.kind == syntax.nkind.N_INTLIT) {
|
if (fi.tnode.rhs.kind == syntax.nkind.N_INTLIT) {
|
||||||
total = fi.tnode.rhs.uval: i32;
|
total = fi.tnode.rhs.uval: i32;
|
||||||
};
|
};
|
||||||
};
|
}; };
|
||||||
for (idx < total) {
|
for (idx < total) {
|
||||||
if (mode == 1) {
|
if (mode == 1) {
|
||||||
emitline("\tMOVQ\t");
|
emitline("\tMOVQ\t");
|
||||||
|
|||||||
16
test/wcc/data/defdim_field_fill/case.ww
Normal file
16
test/wcc/data/defdim_field_fill/case.ww
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
//ww:run-exit 0
|
||||||
|
// structlit `...` repeat-fill on a def-dimensioned [N]T field: the
|
||||||
|
// fill total must come off the stamped array tinfo (rule 13). The
|
||||||
|
// N_INTLIT-only surface read left elements 1..N-1 zero (ww-only).
|
||||||
|
package main;
|
||||||
|
def N: int = 4;
|
||||||
|
type holder = struct { arr: [N]i64, tail: i64 };
|
||||||
|
export fn main() i32 = {
|
||||||
|
let h: holder = holder{ arr = [7...], tail = 9 };
|
||||||
|
if (h.arr[0] != 7) { return 1; };
|
||||||
|
if (h.arr[1] != 7) { return 2; };
|
||||||
|
if (h.arr[2] != 7) { return 3; };
|
||||||
|
if (h.arr[3] != 7) { return 4; };
|
||||||
|
if (h.tail != 9) { return 5; };
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user