From 41483dda42f6eb2ce45b0f8580fc46eacf6390b8 Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 15 Oct 2025 11:18:47 +0200 Subject: c: fix codegen for enum types --- common.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'common.h') 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) { -- cgit v1.2.3