Skip to content

Commit 59d0dcd

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 c09c50d commit 59d0dcd

File tree

1 file changed

+5
-41
lines changed

1 file changed

+5
-41
lines changed

src/goto-programs/goto_convert.cpp

Lines changed: 5 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -706,37 +706,11 @@ void goto_convertt::convert_assign(
706706
do_cpp_new(lhs, to_side_effect_expr(rhs), dest);
707707
}
708708
else if(
709-
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)
709+
rhs.id() == ID_side_effect && rhs.get(ID_statement) != ID_assign &&
710+
rhs.get(ID_statement) != ID_postincrement &&
711+
rhs.get(ID_statement) != ID_preincrement &&
712+
rhs.get(ID_statement) != ID_statement_expression &&
713+
rhs.get(ID_statement) != ID_gcc_conditional_expression)
740714
{
741715
// preserve side effects that will be handled at later stages,
742716
// such as allocate, new operators of other languages, e.g. java, etc
@@ -754,16 +728,6 @@ void goto_convertt::convert_assign(
754728
// do everything else
755729
clean_expr(rhs, dest, mode);
756730

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-
767731
code_assignt new_assign(code);
768732
new_assign.lhs()=lhs;
769733
new_assign.rhs()=rhs;

0 commit comments

Comments
 (0)