@@ -53,16 +53,15 @@ static bool have_to_adjust_float_expressions(const exprt &expr)
53
53
if (dest_type.id ()==ID_floatbv &&
54
54
src_type.id ()==ID_floatbv)
55
55
return true ;
56
- else if (dest_type.id ()==ID_floatbv &&
57
- (src_type.id ()==ID_c_bool ||
58
- src_type.id ()==ID_signedbv ||
59
- src_type.id ()==ID_unsignedbv ||
60
- src_type.id ()==ID_c_enum_tag))
56
+ else if (
57
+ dest_type.id () == ID_floatbv &&
58
+ (src_type.id () == ID_c_bit_field || src_type.id () == ID_signedbv ||
59
+ src_type.id () == ID_unsignedbv || src_type.id () == ID_c_enum_tag))
61
60
return true ;
62
- else if ((dest_type. id ()==ID_signedbv ||
63
- dest_type.id ()== ID_unsignedbv ||
64
- dest_type.id ()==ID_c_enum_tag ) &&
65
- src_type.id ()== ID_floatbv)
61
+ else if (
62
+ (dest_type. id () == ID_signedbv || dest_type.id () == ID_unsignedbv ||
63
+ dest_type. id () == ID_c_enum_tag || dest_type.id () == ID_c_bit_field ) &&
64
+ src_type.id () == ID_floatbv)
66
65
return true ;
67
66
}
68
67
@@ -136,21 +135,26 @@ void adjust_float_expressions(exprt &expr, const exprt &rounding_mode)
136
135
expr.operands ().resize (2 );
137
136
expr.op1 ()=rounding_mode;
138
137
}
139
- else if (dest_type.id ()==ID_floatbv &&
140
- (src_type.id ()==ID_c_bool ||
141
- src_type.id ()==ID_signedbv ||
142
- src_type.id ()==ID_unsignedbv ||
143
- src_type.id ()==ID_c_enum_tag))
138
+ else if (
139
+ dest_type.id () == ID_floatbv &&
140
+ (src_type.id () == ID_signedbv || src_type.id () == ID_unsignedbv ||
141
+ src_type.id () == ID_c_enum_tag || src_type.id () == ID_c_bit_field))
144
142
{
145
143
// casts from integer to float-type might round
146
144
expr.id (ID_floatbv_typecast);
147
145
expr.operands ().resize (2 );
148
146
expr.op1 ()=rounding_mode;
149
147
}
150
- else if ((dest_type.id ()==ID_signedbv ||
151
- dest_type.id ()==ID_unsignedbv ||
152
- dest_type.id ()==ID_c_enum_tag) &&
153
- src_type.id ()==ID_floatbv)
148
+ else if (
149
+ dest_type.id () == ID_floatbv &&
150
+ (src_type.id () == ID_c_bool || src_type.id () == ID_bool))
151
+ {
152
+ // casts from bool or c_bool to float-type do not need rounding
153
+ }
154
+ else if (
155
+ (dest_type.id () == ID_signedbv || dest_type.id () == ID_unsignedbv ||
156
+ dest_type.id () == ID_c_enum_tag || dest_type.id () == ID_c_bit_field) &&
157
+ src_type.id () == ID_floatbv)
154
158
{
155
159
// In C, casts from float to integer always round to zero,
156
160
// irrespectively of the rounding mode that is currently set.
0 commit comments