@@ -838,51 +838,12 @@ void goto_convertt::do_array_op(
838
838
array_op_statement.operands ()=arguments;
839
839
array_op_statement.add_source_location ()=function.source_location ();
840
840
841
- copy (array_op_statement, OTHER, dest);
842
- }
843
-
844
- void goto_convertt::do_array_equal (
845
- const exprt &lhs,
846
- const exprt &function,
847
- const exprt::operandst &arguments,
848
- goto_programt &dest)
849
- {
850
- if (arguments.size ()!=2 )
851
- {
852
- error ().source_location =function.find_source_location ();
853
- error () << " array_equal expects two arguments" << eom;
854
- throw 0 ;
855
- }
856
-
857
- const typet &arg0_type=ns.follow (arguments[0 ].type ());
858
- const typet &arg1_type=ns.follow (arguments[1 ].type ());
841
+ // lhs is only used with array_equal, in all other cases it should be nil (as
842
+ // they are of type void)
843
+ if (id == ID_array_equal)
844
+ array_op_statement.copy_to_operands (lhs);
859
845
860
- if (arg0_type.id ()!=ID_pointer ||
861
- arg1_type.id ()!=ID_pointer)
862
- {
863
- error ().source_location =function.find_source_location ();
864
- error () << " array_equal expects pointer arguments" << eom;
865
- throw 0 ;
866
- }
867
-
868
- if (lhs.is_not_nil ())
869
- {
870
- code_assignt assignment;
871
-
872
- // add dereferencing here
873
- dereference_exprt lhs_array, rhs_array;
874
- lhs_array.op0 ()=arguments[0 ];
875
- rhs_array.op0 ()=arguments[1 ];
876
- lhs_array.type ()=arg0_type.subtype ();
877
- rhs_array.type ()=arg1_type.subtype ();
878
-
879
- assignment.lhs ()=lhs;
880
- assignment.rhs ()=binary_exprt (
881
- lhs_array, ID_array_equal, rhs_array, lhs.type ());
882
- assignment.add_source_location ()=function.source_location ();
883
-
884
- convert (assignment, dest);
885
- }
846
+ copy (array_op_statement, OTHER, dest);
886
847
}
887
848
888
849
bool is_lvalue (const exprt &expr)
@@ -1213,7 +1174,7 @@ void goto_convertt::do_function_call_symbol(
1213
1174
}
1214
1175
else if (identifier==CPROVER_PREFIX " array_equal" )
1215
1176
{
1216
- do_array_equal ( lhs, function, arguments, dest);
1177
+ do_array_op (ID_array_equal, lhs, function, arguments, dest);
1217
1178
}
1218
1179
else if (identifier==CPROVER_PREFIX " array_set" )
1219
1180
{
0 commit comments