@@ -44,10 +44,13 @@ void goto_convertt::remove_assignment(
44
44
45
45
if (statement==ID_assign)
46
46
{
47
- exprt tmp=expr;
48
- tmp.id (ID_code);
49
- // just interpret as code
50
- convert_assign (to_code_assign (to_code (tmp)), dest, mode);
47
+ exprt new_lhs = skip_typecast (expr.op0 ());
48
+ exprt new_rhs =
49
+ typecast_exprt::conditional_cast (expr.op1 (), new_lhs.type ());
50
+ code_assignt assign (std::move (new_lhs), std::move (new_rhs));
51
+ assign.add_source_location () = expr.source_location ();
52
+
53
+ convert_assign (assign, dest, mode);
51
54
}
52
55
else if (statement==ID_assign_plus ||
53
56
statement==ID_assign_minus ||
@@ -107,7 +110,11 @@ void goto_convertt::remove_assignment(
107
110
rhs.type () = expr.op0 ().type ();
108
111
rhs.add_source_location () = expr.source_location ();
109
112
110
- code_assignt assignment (expr.op0 (), rhs);
113
+ exprt new_lhs = skip_typecast (expr.op0 ());
114
+ rhs = typecast_exprt::conditional_cast (rhs, new_lhs.type ());
115
+ rhs.add_source_location () = expr.source_location ();
116
+
117
+ code_assignt assignment (new_lhs, rhs);
111
118
assignment.add_source_location ()=expr.source_location ();
112
119
113
120
convert (assignment, dest, mode);
0 commit comments