aboutsummaryrefslogtreecommitdiff
path: root/src/compiler/builtins.zc
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-15 22:15:38 +0330
committerGravatar zinc <zinc@downsta.ir> 2026-10-15 22:15:38 +0330
commitbe43babc1886fc5efee898b2a3d0285012e511fb (patch)
treeb7ae73e7a6d4c896e2c49b7090168ef589b574af /src/compiler/builtins.zc
parentmerge work/known-bugs: constant-expression precedence, local const in constan... (diff)
definite assignment: reading a local before it is initialized is a compile error (spec 4.1.5, b.1.9)
track linited per local alongside the ownership state; snapshots, exit records and joins carry it, and a join keeps a local set only when every reaching path set it. x = e, a declaration initializer, &x (out-parameter), a full array initializer, or using an aggregate as an address set a local; field and element writes do not set the aggregate. while/for bodies that may run zero times do not count; do/while does. compiler, runtime, std, actor and lsp sources initialize the locals the rule flagged; zc0 accepts = {} brace lists (zeroed). tests: tests/errors/uninit_*.zc, tests/conformance/4-statements/uninit_*.zc
Diffstat (limited to 'src/compiler/builtins.zc')
-rw-r--r--src/compiler/builtins.zc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/compiler/builtins.zc b/src/compiler/builtins.zc
index f40e223..56895e9 100644
--- a/src/compiler/builtins.zc
+++ b/src/compiler/builtins.zc
@@ -464,7 +464,7 @@ int embed_bind(int n, int off, word t, int a, int kind) {
return 0;
}
i = newloc(n); lrsoff[i] = off; rs_note(RS_LOCAL, off);
- ltag[i] = LDECL; lpos[i] = tpack(); lnsz[i] = 0; lleaf[i] = 0; ltype[i] = t;
+ ltag[i] = LDECL; lpos[i] = tpack(); lnsz[i] = 0; lleaf[i] = 0; ltype[i] = t; mark_inited(i);
if (kind == 1) {
larr[i] = 1; fslots = fslots + tsz(t); capture_cell(i, 0);
vaddr(i); lit(a); lit(tsz(t)); callname(s_copy_w); op(O_DROP);
@@ -1094,7 +1094,7 @@ int ckind(int skipname) {
int ckindfloat(int k) { return k == 2 || k == 5; }
// parse an extern declaration: a c function with its signature, and a zc stub for it.
int kw_extern() {
- int rk; word[16] ks; word[16] kst; char*[16] ksn; int np = 0, k; char* fname; char* cname; int i, a, j, n, w, sig, bad = 0; char* buf; word oldimports = module_imports; int pos, len, g; word st, rst; int rn, rsd, sret = 0;
+ int rk; word[16] ks = {}; word[16] kst = {}; char*[16] ksn = {}; int np = 0, k; char* fname; char* cname; int i, a, j, n, w, sig, bad = 0; char* buf; word oldimports = module_imports; int pos, len, g; word st, rst = 0; int rn = 0, rsd, sret = 0;
stmtonly();
next();
rk = ckind(0);
@@ -1544,7 +1544,7 @@ word targ(word t, int i) { return t[6][1 + i]; }
// ---- function types by address ----
word sigof(int f) {
- int i = nsym, s = -1; word[24] ws; int n, k;
+ int i = nsym, s = -1; word[24] ws = {}; int n, k;
while (i) { i--; if (skind[i] == K_FN && sval[i] == f && (sflag[i] & F_DEF)) { s = i; break; } }
if (s < 0) return 0;
if (stype[s]) return stype[s];