Skip to content

Commit 0348b8d

Browse files
committed
fix: add missing integer casts and operations
adds: integer->bool cast bool -> integer cast integer minus operation
1 parent e589516 commit 0348b8d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

src/solvers/smt2/smt2_conv.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -1838,7 +1838,8 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
18381838
src_type.id()==ID_unsignedbv ||
18391839
src_type.id()==ID_c_bool ||
18401840
src_type.id()==ID_fixedbv ||
1841-
src_type.id()==ID_pointer)
1841+
src_type.id()==ID_pointer ||
1842+
src_type.id()==ID_integer)
18421843
{
18431844
out << "(not (= ";
18441845
convert_expr(src);
@@ -2283,6 +2284,17 @@ void smt2_convt::convert_typecast(const typecast_exprt &expr)
22832284
else
22842285
UNEXPECTEDCASE("Unknown typecast "+src_type.id_string()+" -> float");
22852286
}
2287+
else if (dest_type.id()==ID_integer)
2288+
{
2289+
if(src_type.id()==ID_bool)
2290+
{
2291+
out << "(ite ";
2292+
convert_expr(src);
2293+
out <<" 1 0 )";
2294+
}
2295+
else
2296+
UNEXPECTEDCASE("Unknown typecast "+src_type.id_string()+" -> integer");
2297+
}
22862298
else if(dest_type.id()==ID_c_bit_field)
22872299
{
22882300
std::size_t from_width=boolbv_width(src_type);
@@ -3079,7 +3091,15 @@ void smt2_convt::convert_minus(const minus_exprt &expr)
30793091
{
30803092
assert(expr.operands().size()==2);
30813093

3082-
if(expr.type().id()==ID_unsignedbv ||
3094+
if(expr.type().id()==ID_integer)
3095+
{
3096+
out << "(- ";
3097+
convert_expr(expr.op0());
3098+
out << " ";
3099+
convert_expr(expr.op1());
3100+
out << ")";
3101+
}
3102+
else if(expr.type().id()==ID_unsignedbv ||
30833103
expr.type().id()==ID_signedbv ||
30843104
expr.type().id()==ID_fixedbv)
30853105
{

0 commit comments

Comments
 (0)