From 6bb6fb79350945951b26864d2a8c433053bbca0d Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 22 Dec 2025 08:58:43 +0100 Subject: c: Fix some dumb uses of initialized stuff Can't figure out what's wrong with the change to struct expr from 9721d6ba40 but it makes valgrind complain and causes miscompilation of the compiler itself.. --- c/c.h | 12 +++++------- c/lex.c | 10 +++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) (limited to 'c') diff --git a/c/c.h b/c/c.h index 45ce509..a31a1fd 100644 --- a/c/c.h +++ b/c/c.h @@ -25,18 +25,16 @@ enum exprkind { struct expr { uchar t; uchar qual; + ushort narg; /* ECALL */ union type ty; struct span span; union { struct { struct expr *sub; /* child(ren) */ - union { - struct exgetfld { - ushort off; - uchar bitsiz, bitoff; - } fld; /* EGETF */ - ushort narg; /* ECALL */ - }; + struct exgetfld { + ushort off; + uchar bitsiz, bitoff; + } fld; /* EGETF */ }; uvlong u; vlong i; double f; /* ENUMLIT */ struct { diff --git a/c/lex.c b/c/lex.c index 9b6de51..b08a704 100644 --- a/c/lex.c +++ b/c/lex.c @@ -545,11 +545,12 @@ Begin: --lx->chrbuf0; if (lx->chrbuf0 + MAXLITLEN >= countof(lx->chrbuf)) fillchrbuf(lx); - uchar *p = &lx->chrbuf[lx->chrbuf0]; int n = 1; + uchar *p = &lx->chrbuf[lx->chrbuf0]; for (; isppnum(p[n-1], p[n]); ++n) { - if (n >= MAXLITLEN) TooLong: { + if (n >= MAXLITLEN) { lx->chridx = lx->chridxbuf[lx->chrbuf0+n-1]; + TooLong: fatal(&(struct span) {{ idx, lx->chridx - idx, lx->fileid }}, "token is too long"); } @@ -571,7 +572,10 @@ Begin: uchar *p = &lx->chrbuf[lx->chrbuf0]; int n = 1; for (; !aissep(p[n]); ++n) { - if (n >= MAXLITLEN) goto TooLong; + if (n >= MAXLITLEN) { + lx->chridx = lx->chridxbuf[lx->chrbuf0+n-1]; + goto TooLong; + } } tk->blue = 0; tk->len = n; -- cgit v1.2.3