Skip to content

Unwindset parsing: warn when label-based identifier is ambiguous #6769

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
Mar 30, 2022
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
7 changes: 7 additions & 0 deletions regression/cbmc/unwindset2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
int main()
{
// clang-format off
for_loop: for(int i=0; i<5; ++i) { while(i<5) ++i; }
// clang-format on
return 0;
}
9 changes: 9 additions & 0 deletions regression/cbmc/unwindset2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CORE
main.c
--unwindset main.for_loop:2 --unwinding-assertions
^loop identifier main.for_loop provided with unwindset is ambiguous$
^VERIFICATION SUCCESSFUL$
^EXIT=0$
^SIGNAL=0$
--
^warning: ignoring
8 changes: 7 additions & 1 deletion src/goto-instrument/unwindset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,14 @@ void unwindsett::parse_unwindset_one_loop(
location.has_value() && instruction.is_backwards_goto() &&
instruction.source_location() == *location)
{
if(nr.has_value())
{
messaget log{message_handler};
log.warning()
<< "loop identifier " << id
<< " provided with unwindset is ambiguous" << messaget::eom;
}
nr = instruction.loop_number;
break;
}
}
if(!nr.has_value())
Expand Down