aboutsummaryrefslogtreecommitdiffhomepage
path: root/type.h
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-12-15 11:16:38 +0100
committerlemon <lsof@mailbox.org>2025-12-15 11:16:38 +0100
commit068aaef0ea684ecf5f891559aa8e1dae03b8428d (patch)
tree07e9685132f22f45bd5d8fe7c66b00e9ed98ad5e /type.h
parentc244d3c1ba501796152c2278a040cf940b660ea6 (diff)
c: support forward-declared enums
This is a common non-standard GNU extension.
Diffstat (limited to 'type.h')
-rw-r--r--type.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/type.h b/type.h
index 4124dff..decef3c 100644
--- a/type.h
+++ b/type.h
@@ -136,7 +136,7 @@ union type cvtarith(union type a, union type b);
static inline union type
typechild(union type t)
{
- if (t.t == TYENUM) return mktype(t.backing);
+ if (t.t == TYENUM) return mktype(t.backing ? t.backing : typedata[t.dat].backing);
if (t.flag & TFCHLDPRIM) return mktype(t.child);
if (t.flag & TFCHLDISDAT) {
union type chld = mktype(typedata[t.dat].t, .dat = t.dat);
@@ -148,7 +148,7 @@ typechild(union type t)
static inline enum typetag
scalartypet(union type t)
{
- if (t.t == TYENUM) return t.backing;
+ if (t.t == TYENUM) return t.backing ? t.backing : typedata[t.dat].backing;
if (isptrcvt(t)) return TYPTR;
return t.t;
}