From 0fdbe052dcf45546e1b78b731ba2529c2b655396 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Thu, 14 Mar 2019 18:35:40 -0700 Subject: Don't need a table of int maximums --- expr.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/expr.c b/expr.c index 7bc7f4e..8b3df82 100644 --- a/expr.c +++ b/expr.c @@ -241,12 +241,6 @@ inttype(uint64_t val, bool decimal, char *end) {&typellong, "ll", NULL}, {&typeullong, "ull", "llu"}, }; - static const uint64_t max[] = { - [1] = 0xff, - [2] = 0xffff, - [4] = 0xffffffff, - [8] = 0xffffffffffffffff, - }; struct type *t; size_t i, step; @@ -263,7 +257,7 @@ inttype(uint64_t val, bool decimal, char *end) step = i % 2 || decimal ? 2 : 1; for (; i < LEN(limits); i += step) { t = limits[i].type; - if (val <= max[t->size] >> t->basic.issigned) + if (val <= (uint64_t)-1 >> (8 - t->size << 3) + t->basic.issigned) return t; } error(&tok.loc, "no suitable type for constant '%s'", tok.lit); -- cgit v1.2.3