aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-22 08:58:43 +0100
committerlemon <lsof@mailbox.org>2025-12-22 08:58:43 +0100
commit6bb6fb79350945951b26864d2a8c433053bbca0d (patch)
treeb92f9ea88f5d6aae2b798d6035ce1d066e1ed917
parent6fc94fd3f7edad42e77426153f9933376b621142 (diff)
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..
-rw-r--r--c/c.h12
-rw-r--r--c/lex.c10
2 files changed, 12 insertions, 10 deletions
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;