let do_promotion ~with_alarms ~src_typ ~dest_type v e_src =
match dest_type, src_typ with
| TFloat _, TInt _ ->
Cvalue_type.V.cast_int_to_float ~with_alarms (get_rounding_mode()) v
| TInt (kind,_), TFloat _ ->
let size = bitsSizeOf dest_type in
let signed = isSigned kind in
let alarm_use_as_float, alarm_overflow, r =
Cvalue_type.V.cast_float_to_int ~signed ~size v
in
if alarm_use_as_float
then begin
Value_parameters.warning ~current:true ~once:true
"converting %a to float: assert(Ook)"
!d_exp e_src;
end;
if alarm_overflow
then
Value_parameters.warning ~current:true ~once:true
"Overflow in cast of %a (%a) from floating-point to integer: assert(Ook)"
!d_exp e_src
Cvalue_type.V.pretty v;
r
| _, _ -> v