@@ -691,7 +691,7 @@ void code_contractst::instrument_assign_statement(
691691 instruction_iterator->source_location ));
692692 alias_assertion.instructions .back ().source_location .set_comment (
693693 " Check that " + from_expr (ns, lhs.id (), lhs) + " is assignable" );
694- int lines_to_iterate = alias_assertion.instructions .size ();
694+ size_t lines_to_iterate = alias_assertion.instructions .size ();
695695 program.insert_before_swap (instruction_iterator, alias_assertion);
696696 std::advance (instruction_iterator, lines_to_iterate);
697697}
@@ -742,7 +742,7 @@ void code_contractst::instrument_call_statement(
742742 assigns_clause.add_pointer_target (rhs);
743743 goto_programt &pointer_capture = new_target->get_init_block ();
744744
745- int lines_to_iterate = pointer_capture.instructions .size ();
745+ size_t lines_to_iterate = pointer_capture.instructions .size ();
746746 program.insert_before_swap (local_instruction_iterator, pointer_capture);
747747 std::advance (instruction_iterator, lines_to_iterate + 1 );
748748 }
@@ -909,21 +909,27 @@ void code_contractst::check_frame_conditions(
909909
910910 // Create a list of variables that are okay to assign.
911911 std::set<irep_idt> freely_assignable_symbols;
912+ // Add all parameters that are not pointers to the freely assignable set
912913 for (code_typet::parametert param : type.parameters ())
913914 {
914- freely_assignable_symbols.insert (param.get_identifier ());
915+ if (param.type ().id () != ID_pointer)
916+ {
917+ freely_assignable_symbols.insert (param.get_identifier ());
918+ }
915919 }
916920
917- goto_programt::instructionst::iterator instruction_it =
918- program.instructions .begin ();
919-
920921 // Create temporary variables to hold the assigns
921922 // clause targets before they can be modified.
922923 goto_programt standin_decls = assigns.init_block (target.location );
924+ // Create dead statements for temporary variables
923925 goto_programt mark_dead =
924926 assigns.dead_stmts (target.location , target.name , target.mode );
925927
926- int lines_to_iterate = standin_decls.instructions .size ();
928+ // Skip lines with temporary variable declarations
929+ size_t lines_to_iterate = standin_decls.instructions .size ();
930+
931+ goto_programt::instructionst::iterator instruction_it =
932+ program.instructions .begin ();
927933 program.insert_before_swap (instruction_it, standin_decls);
928934 std::advance (instruction_it, lines_to_iterate);
929935
@@ -972,7 +978,6 @@ void code_contractst::check_frame_conditions(
972978 }
973979
974980 // Make sure the temporary symbols are marked dead
975- lines_to_iterate = mark_dead.instructions .size ();
976981 program.insert_before_swap (instruction_it, mark_dead);
977982}
978983
0 commit comments