File tree Expand file tree Collapse file tree 3 files changed +40
-3
lines changed
regression/goto-synthesizer/do_while_loop_0 Expand file tree Collapse file tree 3 files changed +40
-3
lines changed Original file line number Diff line number Diff line change 1+ int main ()
2+ {
3+ int result = 0 ;
4+ do
5+ {
6+ result += 1 ;
7+ } while (0 == 1 );
8+ }
Original file line number Diff line number Diff line change 1+ CORE
2+ main.c
3+ --pointer-check
4+ ^EXIT=0$
5+ ^SIGNAL=0$
6+ ^VERIFICATION SUCCESSFUL$
7+ --
8+ ^warning: ignoring
9+ --
10+ Check if synthesizer works for do {} while (0).
Original file line number Diff line number Diff line change @@ -99,15 +99,34 @@ void enumerative_loop_contracts_synthesizert::init_candidates()
9999 if (loop_head_and_content.second .size () <= 1 )
100100 continue ;
101101
102- goto_programt::const_targett loop_end =
102+ goto_programt::targett loop_end =
103103 get_loop_end_from_loop_head_and_content_mutable (
104104 loop_head_and_content.first , loop_head_and_content.second );
105105
106106 loop_idt new_id (function_p.first , loop_end->loop_number );
107107 loop_cfg_infot cfg_info (function_p.second , loop_head_and_content.second );
108108
109- log.debug () << " Initialize candidates for the loop at "
110- << loop_end->source_location () << messaget::eom;
109+ log.progress () << " Initialize candidates for the loop at "
110+ << loop_end->source_location () << messaget::eom;
111+
112+ // Turn do while loops of form
113+ //
114+ // do
115+ // { loop body }
116+ // while (0)
117+ //
118+ // into non-loop block
119+ //
120+ // { loop body }
121+ // skip
122+ //
123+ if (
124+ loop_end->is_goto () &&
125+ simplify_expr (loop_end->condition (), ns) == false_exprt ())
126+ {
127+ loop_end->turn_into_skip ();
128+ continue ;
129+ }
111130
112131 // we only synthesize invariants and assigns for unannotated loops
113132 if (loop_end->condition ().find (ID_C_spec_loop_invariant).is_nil ())
You can’t perform that action at this time.
0 commit comments