diff --git a/jbmc/regression/jbmc/JumpSimplification/Test.class b/jbmc/regression/jbmc/JumpSimplification/Test.class new file mode 100644 index 00000000000..c2824188410 Binary files /dev/null and b/jbmc/regression/jbmc/JumpSimplification/Test.class differ diff --git a/jbmc/regression/jbmc/JumpSimplification/Test.java b/jbmc/regression/jbmc/JumpSimplification/Test.java new file mode 100644 index 00000000000..85b3035f96c --- /dev/null +++ b/jbmc/regression/jbmc/JumpSimplification/Test.java @@ -0,0 +1,14 @@ +public class Test { + + public int foo(int i) { + int x = 0; + if (i > 0) { + x++; + } + else + { + x--; + } + return x + 1000; + } +} diff --git a/jbmc/regression/jbmc/JumpSimplification/test.desc b/jbmc/regression/jbmc/JumpSimplification/test.desc new file mode 100644 index 00000000000..3f7c1243237 --- /dev/null +++ b/jbmc/regression/jbmc/JumpSimplification/test.desc @@ -0,0 +1,10 @@ +CORE +Test.class +--show-goto-functions --function Test.foo +activate-multi-line-match +EXIT=0 +SIGNAL=0 +IF \w* <= 0 THEN GOTO 1\n\s*//.*\n\s*//.*\n\s*\w*:: +-- +IF !\(\w* <= 0\) THEN GOTO 1\n\s*//.*\n.*GOTO 2\n\s*//.*\n\s*//.*\n\s*1: \w*:: +^warning: ignoring diff --git a/src/goto-programs/goto_convert.cpp b/src/goto-programs/goto_convert.cpp index 298f61aefb5..9833cc07775 100644 --- a/src/goto-programs/goto_convert.cpp +++ b/src/goto-programs/goto_convert.cpp @@ -1460,8 +1460,10 @@ void goto_convertt::convert_goto( const codet &code, goto_programt &dest) { - // this instruction will turn into a goto during post-processing - goto_programt::targett t=dest.add_instruction(NO_INSTRUCTION_TYPE); + // this instruction will be completed during post-processing + // it is required to mark this as GOTO in order to enable + // simplifications in generate_ifthenelse + goto_programt::targett t = dest.add_instruction(GOTO); t->source_location=code.source_location(); t->code=code;