aboutsummaryrefslogtreecommitdiffhomepage
path: root/parse.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2023-06-08 11:02:25 +0200
committerlemon <lsof@mailbox.org>2023-06-08 11:02:25 +0200
commit22e20cf906fa3904eedfe34efc58a7b56116ce42 (patch)
tree2a14de98971d30e640908609bbadd2392efc1ad9 /parse.c
parent86625b1166bd39e28b4dd4995ed6cd88c0bdde7e (diff)
pointer arith bugifx
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 1ea9dbd..44e6a4f 100644
--- a/parse.c
+++ b/parse.c
@@ -294,6 +294,7 @@ argpromote(union type t)
{
if (isint(t)) t.t = intpromote(t.t);
else if (t.t == TYFLOAT) t.t = TYDOUBLE;
+ else if (t.t == TYARRAY) return mkptrtype(typechild(t), t.flag & TFCHLDQUAL);
return t;
}
@@ -499,7 +500,7 @@ bintypecheck(const struct span *span, enum toktag tt, struct expr *lhs, struct e
/* num +/- num */
ty = cvtarith(ty, rhs->ty);
assert(ty.t);
- } else if ((ty.t == TYPTR || ty.t == TYARRAY) && rhs->ty.t == TYINT) {
+ } else if ((ty.t == TYPTR || ty.t == TYARRAY) && isint(rhs->ty)) {
/* ptr +/- int */
union type pointee = typechild(ty);
if (isincomplete(pointee))