Skip to content

Commit 56c7da7

Browse files
author
Daniel Kroening
committed
add typing for convert_dowhile
1 parent cbe16b3 commit 56c7da7

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

src/goto-programs/goto_convert.cpp

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ void goto_convertt::convert(
479479
else if(statement==ID_while)
480480
convert_while(to_code_while(code), dest, mode);
481481
else if(statement==ID_dowhile)
482-
convert_dowhile(code, dest, mode);
482+
convert_dowhile(to_code_dowhile(code), dest, mode);
483483
else if(statement==ID_switch)
484484
convert_switch(to_code_switch(code), dest, mode);
485485
else if(statement==ID_break)
@@ -1131,21 +1131,14 @@ void goto_convertt::convert_while(
11311131
}
11321132

11331133
void goto_convertt::convert_dowhile(
1134-
const codet &code,
1134+
const code_dowhilet &code,
11351135
goto_programt &dest,
11361136
const irep_idt &mode)
11371137
{
1138-
if(code.operands().size()!=2)
1139-
{
1140-
error().source_location=code.find_source_location();
1141-
error() << "dowhile takes two operands" << eom;
1142-
throw 0;
1143-
}
1144-
11451138
// save source location
1146-
source_locationt condition_location=code.op0().find_source_location();
1139+
source_locationt condition_location=code.cond().find_source_location();
11471140

1148-
exprt cond=code.op0();
1141+
exprt cond=code.cond();
11491142

11501143
goto_programt sideeffects;
11511144
clean_expr(cond, sideeffects, mode);
@@ -1183,7 +1176,7 @@ void goto_convertt::convert_dowhile(
11831176

11841177
// do the w label
11851178
goto_programt tmp_w;
1186-
convert(to_code(code.op1()), tmp_w, mode);
1179+
convert(code.body(), tmp_w, mode);
11871180
goto_programt::targett w=tmp_w.instructions.begin();
11881181

11891182
// y: if(c) goto w;

src/goto-programs/goto_convert_class.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,10 @@ class goto_convertt:public messaget
234234
const code_whilet &code,
235235
goto_programt &dest,
236236
const irep_idt &mode);
237-
void
238-
convert_dowhile(const codet &code, goto_programt &dest, const irep_idt &mode);
237+
void convert_dowhile(
238+
const code_dowhilet &code,
239+
goto_programt &dest,
240+
const irep_idt &mode);
239241
void convert_assume(
240242
const code_assumet &code,
241243
goto_programt &dest,

0 commit comments

Comments
 (0)