Skip to content

Commit c8a09a0

Browse files
geoffw0Copilot
andcommitted
C++: Test goto target counts
Exercise multiple forward and backward targets and a single forward target for cpp/use-of-goto. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1a733a6 commit c8a09a0

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
void multiple_forward_and_backward_targets_one() { // $ Alert
2+
goto forward_one;
3+
goto forward_two;
4+
forward_one:
5+
;
6+
forward_two:
7+
;
8+
backward_one:
9+
;
10+
backward_two:
11+
;
12+
goto backward_one;
13+
goto backward_two;
14+
}
15+
16+
void multiple_forward_and_backward_targets_two() { // $ Alert
17+
goto next_one;
18+
goto next_two;
19+
next_one:
20+
;
21+
next_two:
22+
;
23+
earlier_one:
24+
;
25+
earlier_two:
26+
;
27+
goto earlier_one;
28+
goto earlier_two;
29+
}
30+
31+
void one_forward_target_is_not_enough() {
32+
goto forward;
33+
forward:
34+
;
35+
backward_one:
36+
;
37+
backward_two:
38+
;
39+
goto backward_one;
40+
goto backward_two;
41+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
| UseOfGoto.cpp:1:6:1:46 | definition of multiple_forward_and_backward_targets_one | Multiple forward and backward goto statements may make function multiple_forward_and_backward_targets_one hard to understand. |
2+
| UseOfGoto.cpp:16:6:16:46 | definition of multiple_forward_and_backward_targets_two | Multiple forward and backward goto statements may make function multiple_forward_and_backward_targets_two hard to understand. |
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
query: Best Practices/UseOfGoto.ql
2+
postprocess: utils/test/InlineExpectationsTestQuery.ql

0 commit comments

Comments
 (0)