From 0877e32e0bb836a1b3b34d678f0c68f852c55ff3 Mon Sep 17 00:00:00 2001 From: Amos Robinson Date: Tue, 20 Apr 2021 02:02:30 +1000 Subject: Elab bitfields: check size of type <=32bit rather than checking rank (#387) When desugaring a bitfield, allow any integral type that is 32 bits or smaller. Previously this was checking the rank of the type rather than the size. This rank check caused issues with standard headers that declare `uint32_t` to be an `unsigned long` rather than an `unsigned int`. Here, any bitfields declared as `uint32_t` were failing to compile even though they are still actually 32 bits. Co-authored-by: Amos Robinson --- cparser/Elab.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cparser') diff --git a/cparser/Elab.ml b/cparser/Elab.ml index 25e4a980..05717d97 100644 --- a/cparser/Elab.ml +++ b/cparser/Elab.ml @@ -1001,7 +1001,7 @@ and elab_field_group env = function | TInt(ik, _) -> ik | TEnum(_, _) -> enum_ikind | _ -> ILongLong (* trigger next error message *) in - if integer_rank ik > integer_rank IInt then begin + if sizeof_ikind ik > sizeof_ikind IInt then begin error loc "the type of bit-field '%a' must be an integer type no bigger than 'int'" pp_field id; None,env -- cgit