Skip to content

Goto crossing scopes: fix scope tree entry of conditions #8187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions regression/cbmc/declaration-goto/no-duplicate-decl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
int foo()
{
return 1;
}

int main()
{
if(foo())
goto out;

return 1;

out:
__CPROVER_assert(0, "false");
return 0;
}
11 changes: 11 additions & 0 deletions regression/cbmc/declaration-goto/no-duplicate-decl.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
no-duplicate-decl.c
--show-goto-functions
^[[:space:]]*DECL main::\$tmp::return_value_foo
^EXIT=0$
^SIGNAL=0$
--
^[[:space:]]*DECL going_to::out
^[[:space:]]*\d+: DECL main::\$tmp::return_value_foo
--
Test that no loop back to the declaration is generated.
1 change: 1 addition & 0 deletions regression/validate-trace-xml-schema/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
['xml-interface1', 'test_wrong_flag.desc'],
# these want --show-goto-functions instead of producing a trace
['integer-assignments1', 'integer-typecheck.desc'],
['declaration-goto', 'no-duplicate-decl.desc'],
['destructors', 'compound_literal.desc'],
['destructors', 'enter_lexical_block.desc'],
['enum_is_in_range', 'enum_test3-simplified.desc'],
Expand Down
6 changes: 3 additions & 3 deletions src/ansi-c/goto-conversion/goto_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1597,6 +1597,9 @@ void goto_convertt::convert_ifthenelse(
return convert_ifthenelse(new_if0, dest, mode);
}

exprt tmp_guard = code.cond();
clean_expr(tmp_guard, dest, mode);

// convert 'then'-branch
goto_programt tmp_then;
convert(code.then_case(), tmp_then, mode);
Expand All @@ -1616,9 +1619,6 @@ void goto_convertt::convert_ifthenelse(
: code.else_case().source_location();
}

exprt tmp_guard = code.cond();
clean_expr(tmp_guard, dest, mode);

generate_ifthenelse(
tmp_guard,
source_location,
Expand Down
Loading