@@ -43,44 +43,57 @@ bool to_integer(const constant_exprt &expr, mp_integer &int_value)
43
43
}
44
44
else if (type_id==ID_unsignedbv)
45
45
{
46
- int_value = bv2integer (id2string (value), false );
46
+ const auto width = to_unsignedbv_type (type).get_width ();
47
+ int_value = bv2integer (id2string (value), width, false );
47
48
return false ;
48
49
}
49
50
else if (type_id==ID_signedbv)
50
51
{
51
- int_value = bv2integer (id2string (value), true );
52
+ const auto width = to_signedbv_type (type).get_width ();
53
+ int_value = bv2integer (id2string (value), width, true );
52
54
return false ;
53
55
}
54
56
else if (type_id==ID_c_bool)
55
57
{
56
- int_value = bv2integer (id2string (value), false );
58
+ const auto width = to_c_bool_type (type).get_width ();
59
+ int_value = bv2integer (id2string (value), width, false );
57
60
return false ;
58
61
}
59
62
else if (type_id==ID_c_enum)
60
63
{
61
64
const typet &subtype=to_c_enum_type (type).subtype ();
62
65
if (subtype.id ()==ID_signedbv)
63
66
{
64
- int_value = bv2integer (id2string (value), true );
67
+ const auto width = to_signedbv_type (type).get_width ();
68
+ int_value = bv2integer (id2string (value), width, true );
65
69
return false ;
66
70
}
67
71
else if (subtype.id ()==ID_unsignedbv)
68
72
{
69
- int_value = bv2integer (id2string (value), false );
73
+ const auto width = to_unsignedbv_type (type).get_width ();
74
+ int_value = bv2integer (id2string (value), width, false );
70
75
return false ;
71
76
}
72
77
}
73
78
else if (type_id==ID_c_bit_field)
74
79
{
75
- const typet &subtype = to_c_bit_field_type (type).subtype ();
80
+ const auto &c_bit_field_type = to_c_bit_field_type (type);
81
+ const auto width = c_bit_field_type.get_width ();
82
+ const typet &subtype = c_bit_field_type.subtype ();
83
+
76
84
if (subtype.id ()==ID_signedbv)
77
85
{
78
- int_value = bv2integer (id2string (value), true );
86
+ int_value = bv2integer (id2string (value), width, true );
79
87
return false ;
80
88
}
81
89
else if (subtype.id ()==ID_unsignedbv)
82
90
{
83
- int_value = bv2integer (id2string (value), false );
91
+ int_value = bv2integer (id2string (value), width, false );
92
+ return false ;
93
+ }
94
+ else if (subtype.id ()==ID_c_bool)
95
+ {
96
+ int_value = bv2integer (id2string (value), width, false );
84
97
return false ;
85
98
}
86
99
}
0 commit comments