From e0146901a2857e7ddaa249964cc49726c496d754 Mon Sep 17 00:00:00 2001 From: Xavier Leroy Date: Thu, 17 Nov 2016 13:36:14 +0100 Subject: C2C: wrong translation of 'switch' over arguments of type 'long' if 'long' is 64 bits It was wrongly assumed that 'long' is 32 bits. (Reported by Michael Schmidt.) --- cfrontend/C2C.ml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'cfrontend/C2C.ml') diff --git a/cfrontend/C2C.ml b/cfrontend/C2C.ml index c0c62daa..7ba39be4 100644 --- a/cfrontend/C2C.ml +++ b/cfrontend/C2C.ml @@ -578,10 +578,11 @@ let string_of_type ty = Format.pp_print_flush fb (); Buffer.contents b -let is_longlong env ty = +let is_int64 env ty = match Cutil.unroll env ty with - | C.TInt((C.ILongLong|C.IULongLong), _) -> true - | _ -> false + | C.TInt(k, _) -> Cutil.sizeof_ikind k = 8 + | C.TEnum(_, _) -> false + | _ -> assert false (** Floating point constants *) @@ -1022,7 +1023,7 @@ let rec convertStmt env s = end; let te = convertExpr env e in swrap (Ctyping.sswitch te - (convertSwitch env (is_longlong env e.etyp) cases)) + (convertSwitch env (is_int64 env e.etyp) cases)) | C.Slabeled(C.Slabel lbl, s1) -> Slabel(intern_string lbl, convertStmt env s1) | C.Slabeled(C.Scase _, _) -> -- cgit