cproc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/cproc
Log | Files | Refs | Submodules | README | LICENSE

commit 06c40b7914efefaaf85392353537a28c0ece3b47
parent 212dd57e0a870e8fc5532477583e36e465825c5b
Author: Michael Forney <mforney@mforney.org>
Date:   Wed, 24 Apr 2019 21:16:11 -0700

eval: Check that expression has integer type before checking if it's signed

It could be an integer constant cast to a pointer type.

Diffstat:
Meval.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/eval.c b/eval.c @@ -14,7 +14,7 @@ cast(struct expr *expr) size = expr->type->size; if (expr->type->prop & PROPFLOAT) size |= F; - else if (expr->type->basic.issigned) + else if (expr->type->prop & PROPINT && expr->type->basic.issigned) size |= S; switch (size) { case 1: expr->constant.i = (uint8_t)expr->constant.i; break; @@ -33,7 +33,7 @@ binary(struct expr *expr, enum tokenkind op, struct expr *l, struct expr *r) expr->kind = EXPRCONST; if (l->type->prop & PROPFLOAT) op |= F; - else if (l->type->basic.issigned) + else if (l->type->prop & PROPINT && l->type->basic.issigned) op |= S; switch (op) { case TMUL: