diff options
author | Michael Forney <mforney@mforney.org> | 2019-03-14 18:35:40 -0700 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2019-03-14 18:35:40 -0700 |
commit | 0fdbe052dcf45546e1b78b731ba2529c2b655396 (patch) | |
tree | c0b71bc981e3880a41ba848b088a292617802521 | |
parent | f8224f9d814b111e9841c8c3e9735046290b55a6 (diff) | |
download | cproc-0fdbe052dcf45546e1b78b731ba2529c2b655396.tar.xz |
Don't need a table of int maximums
-rw-r--r-- | expr.c | 8 |
1 files changed, 1 insertions, 7 deletions
@@ -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); |