From 22e20cf906fa3904eedfe34efc58a7b56116ce42 Mon Sep 17 00:00:00 2001 From: lemon Date: Thu, 8 Jun 2023 11:02:25 +0200 Subject: pointer arith bugifx --- parse.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)) -- cgit v1.2.3