aboutsummaryrefslogtreecommitdiffhomepage
path: root/common.h
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-10-15 11:18:47 +0200
committerlemon <lsof@mailbox.org>2025-10-15 11:18:47 +0200
commit41483dda42f6eb2ce45b0f8580fc46eacf6390b8 (patch)
treeb804c23ae9f3539234a2d384f991c898760975cb /common.h
parent347d237a114495c0a9b9d14d38551d544dca021d (diff)
c: fix codegen for enum types
Diffstat (limited to 'common.h')
-rw-r--r--common.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/common.h b/common.h
index 0269aa7..e6f36bf 100644
--- a/common.h
+++ b/common.h
@@ -203,8 +203,8 @@ union type {
#define isaggt(t) in_range((t), TYSTRUCT, TYUNION)
#define isprim(ty) isprimt((ty).t)
#define isint(ty) isintt((ty).t)
-#define issigned(ty) issignedt((ty).t)
-#define isunsigned(ty) isunsignedt((ty).t)
+#define issigned(ty) issignedt(scalartypet(ty))
+#define isunsigned(ty) isunsignedt(scalartypet(ty))
#define isflt(ty) isfltt((ty).t)
#define isarith(ty) isaritht((ty).t)
#define isscalar(ty) isscalart((ty).t)
@@ -317,6 +317,11 @@ typechild(union type t)
}
return typedata[t.dat].child;
}
+static inline enum typetag
+scalartypet(union type t)
+{
+ return t.t == TYENUM ? t.backing : t.t;
+}
static inline uint
typearrlen(union type t)
{