aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2016-11-17 13:36:14 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2016-11-17 13:36:14 +0100
commite0146901a2857e7ddaa249964cc49726c496d754 (patch)
treec9d51866363dc5589e998d8ebf8adb922af1dbbb
parent4eb3efa2ccbf58c59a8d181c7d616b3d0c06e02b (diff)
downloadcompcert-e0146901a2857e7ddaa249964cc49726c496d754.tar.gz
compcert-e0146901a2857e7ddaa249964cc49726c496d754.zip
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.)
-rw-r--r--cfrontend/C2C.ml9
1 files changed, 5 insertions, 4 deletions
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 _, _) ->