From b1a906b970e1f55c1a3e6786cddb08719216ade3 Mon Sep 17 00:00:00 2001 From: Michael Matz Date: Sun, 7 Aug 2016 00:09:10 +0200 Subject: enums and ints are compatible --- tccgen.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tccgen.c') diff --git a/tccgen.c b/tccgen.c index aafea36..7c8bc32 100644 --- a/tccgen.c +++ b/tccgen.c @@ -2565,6 +2565,14 @@ static int compare_types(CType *type1, CType *type2, int unqualified) t1 &= ~VT_DEFSIGN; t2 &= ~VT_DEFSIGN; } + if ((t1 & VT_BTYPE) == VT_ENUM) { + /* An enum is compatible with (unsigned) int. */ + t1 = VT_INT | (t1 & ~VT_BTYPE); + } + if ((t2 & VT_BTYPE) == VT_ENUM) { + /* An enum is compatible with (unsigned) int. */ + t2 = VT_INT | (t2 & ~VT_BTYPE); + } /* XXX: bitfields ? */ if (t1 != t2) return 0; -- cgit v1.3.1