diff options
| author | Michael Forney <mforney@mforney.org> | 2019-04-24 21:16:11 -0700 |
|---|---|---|
| committer | Michael Forney <mforney@mforney.org> | 2019-04-24 22:32:22 -0700 |
| commit | 06c40b7914efefaaf85392353537a28c0ece3b47 (patch) | |
| tree | de537785377f327d1cf063a7af462b859d44e729 | |
| parent | 212dd57e0a870e8fc5532477583e36e465825c5b (diff) | |
| download | cproc-06c40b7914efefaaf85392353537a28c0ece3b47.tar.xz | |
eval: Check that expression has integer type before checking if it's signed
It could be an integer constant cast to a pointer type.
| -rw-r--r-- | eval.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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: |
