From 06c40b7914efefaaf85392353537a28c0ece3b47 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Wed, 24 Apr 2019 21:16:11 -0700 Subject: eval: Check that expression has integer type before checking if it's signed It could be an integer constant cast to a pointer type. --- eval.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eval.c b/eval.c index 20eda9b..a244c8a 100644 --- 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: -- cgit v1.2.3