Skip to content
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
8 changes: 8 additions & 0 deletions regression/goto-analyzer/label/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
int main()
{
goto ERROR;

return 0;
ERROR:
return 1;
}
12 changes: 12 additions & 0 deletions regression/goto-analyzer/label/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
main.c
--show-goto-functions --error-label ERROR
Labels: ERROR$
ASSIGN main#return_value := 1$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
--
This test ensures that removal of return values (confirmed by the existence of
the ASSIGN instruction) preserves labels attached to the return statement.
2 changes: 2 additions & 0 deletions src/goto-programs/remove_returns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ void remove_returnst::replace_returns(
code_assignt assignment(*return_symbol, instruction.return_value());

// now turn the `return' into `assignment'
auto labels = std::move(instruction.labels);
instruction = goto_programt::make_assignment(
assignment, instruction.source_location());
instruction.labels = std::move(labels);
}
else
instruction.turn_into_skip();
Expand Down