aboutsummaryrefslogtreecommitdiff
path: root/type.c
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2024-03-21 16:43:00 -0700
committerMichael Forney <mforney@mforney.org>2024-03-21 17:33:40 -0700
commitd1d23429f5dc3d78b03b318a7d349ad71a6c97fa (patch)
tree072e44175ebd75970565e9eb3b893bada3bbdd2a /type.c
parent8bed97beaea3839369a947ea741aa083e76ca014 (diff)
decl: Add support for enums with large values and fixed underlying types
Fixes: https://todo.sr.ht/~mcf/cproc/64
Diffstat (limited to 'type.c')
-rw-r--r--type.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/type.c b/type.c
index ea9e56e..02e9a82 100644
--- a/type.c
+++ b/type.c
@@ -261,6 +261,15 @@ typemember(struct type *t, const char *name, unsigned long long *offset)
return NULL;
}
+bool
+typehasint(struct type *t, unsigned long long i, bool sign)
+{
+ assert(t->prop & PROPINT);
+ if (sign && i >= -1ull << 63)
+ return t->u.basic.issigned && i >= -1ull << (t->size << 3) - 1;
+ return i <= 0xffffffffffffffffull >> (8 - t->size << 3) + t->u.basic.issigned;
+}
+
struct param *
mkparam(char *name, struct type *t, enum typequal tq)
{