From 068aaef0ea684ecf5f891559aa8e1dae03b8428d Mon Sep 17 00:00:00 2001 From: lemon Date: Mon, 15 Dec 2025 11:16:38 +0100 Subject: c: support forward-declared enums This is a common non-standard GNU extension. --- type.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'type.h') 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; } -- cgit v1.2.3