Skip to content

Commit 3374d9c

Browse files
committed
Remove handling of typecast-on-lhs
Language front-ends should not generate such code, and even if there is a goto program having such we do handle it in the back-end (such as goto-symex) anyway.
1 parent 3a8b34d commit 3374d9c

File tree

1 file changed

+5
-40
lines changed

1 file changed

+5
-40
lines changed

src/goto-programs/goto_convert.cpp

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -707,36 +707,11 @@ void goto_convertt::convert_assign(
707707
}
708708
else if(
709709
rhs.id() == ID_side_effect &&
710-
(rhs.get(ID_statement) == ID_assign ||
711-
rhs.get(ID_statement) == ID_postincrement ||
712-
rhs.get(ID_statement) == ID_preincrement ||
713-
rhs.get(ID_statement) == ID_statement_expression ||
714-
rhs.get(ID_statement) == ID_gcc_conditional_expression))
715-
{
716-
// handle above side effects
717-
clean_expr(rhs, dest, mode);
718-
719-
if(lhs.id() == ID_typecast)
720-
{
721-
DATA_INVARIANT(
722-
lhs.operands().size() == 1, "Typecast must have one operand");
723-
724-
// add a typecast to the rhs
725-
exprt new_rhs = rhs;
726-
rhs.make_typecast(lhs.op0().type());
727-
728-
// remove typecast from lhs
729-
exprt tmp = lhs.op0();
730-
lhs.swap(tmp);
731-
}
732-
733-
code_assignt new_assign(code);
734-
new_assign.lhs() = lhs;
735-
new_assign.rhs() = rhs;
736-
737-
copy(new_assign, ASSIGN, dest);
738-
}
739-
else if(rhs.id() == ID_side_effect)
710+
rhs.get(ID_statement) != ID_assign &&
711+
rhs.get(ID_statement) != ID_postincrement &&
712+
rhs.get(ID_statement) != ID_preincrement &&
713+
rhs.get(ID_statement) != ID_statement_expression &&
714+
rhs.get(ID_statement) != ID_gcc_conditional_expression)
740715
{
741716
// preserve side effects that will be handled at later stages,
742717
// such as allocate, new operators of other languages, e.g. java, etc
@@ -754,16 +729,6 @@ void goto_convertt::convert_assign(
754729
// do everything else
755730
clean_expr(rhs, dest, mode);
756731

757-
if(lhs.id()==ID_typecast)
758-
{
759-
// add a typecast to the rhs
760-
rhs.make_typecast(to_typecast_expr(lhs).op().type());
761-
762-
// remove typecast from lhs
763-
exprt tmp=lhs.op0();
764-
lhs.swap(tmp);
765-
}
766-
767732
code_assignt new_assign(code);
768733
new_assign.lhs()=lhs;
769734
new_assign.rhs()=rhs;

0 commit comments

Comments
 (0)