Skip to content

Commit 6298288

Browse files
authored
Merge pull request #6769 from tautschnig/feature/unwindset-warning
Unwindset parsing: warn when label-based identifier is ambiguous
2 parents ec13391 + f972150 commit 6298288

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

regression/cbmc/unwindset2/main.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
int main()
2+
{
3+
// clang-format off
4+
for_loop: for(int i=0; i<5; ++i) { while(i<5) ++i; }
5+
// clang-format on
6+
return 0;
7+
}

regression/cbmc/unwindset2/test.desc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
main.c
3+
--unwindset main.for_loop:2 --unwinding-assertions
4+
^loop identifier main.for_loop provided with unwindset is ambiguous$
5+
^VERIFICATION SUCCESSFUL$
6+
^EXIT=0$
7+
^SIGNAL=0$
8+
--
9+
^warning: ignoring

src/goto-instrument/unwindset.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,14 @@ void unwindsett::parse_unwindset_one_loop(
134134
location.has_value() && instruction.is_backwards_goto() &&
135135
instruction.source_location() == *location)
136136
{
137+
if(nr.has_value())
138+
{
139+
messaget log{message_handler};
140+
log.warning()
141+
<< "loop identifier " << id
142+
<< " provided with unwindset is ambiguous" << messaget::eom;
143+
}
137144
nr = instruction.loop_number;
138-
break;
139145
}
140146
}
141147
if(!nr.has_value())

0 commit comments

Comments
 (0)