Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e1efdd7

Browse files
committed
CPP: Add a test where continue is used in a switch to exit the loop.
1 parent 3337a85 commit e1efdd7

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
| test.cpp:13:4:13:12 | continue; | This 'continue' never re-runs the loop - the $@ is always false. | test.cpp:16:11:16:15 | 0 | loop condition |
22
| test.cpp:59:5:59:13 | continue; | This 'continue' never re-runs the loop - the $@ is always false. | test.cpp:62:12:62:16 | 0 | loop condition |
3+
| test.cpp:88:4:88:12 | continue; | This 'continue' never re-runs the loop - the $@ is always false. | test.cpp:93:11:93:11 | 0 | loop condition |

cpp/ql/test/query-tests/Likely Bugs/ContinueInFalseLoop/test.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
bool cond();
33

4-
void test1()
4+
void test1(int x)
55
{
66
int i;
77

@@ -72,4 +72,23 @@ void test1()
7272
break;
7373
} while (true);
7474
} while (false);
75+
76+
do
77+
{
78+
switch (x)
79+
{
80+
case 1:
81+
// do [1]
82+
83+
break; // break out of the switch
84+
85+
default:
86+
// do [2]
87+
88+
continue; // break out of the loop entirely, skipping [3] [FALSE POSITIVE]
89+
};
90+
91+
// do [3]
92+
93+
} while (0);
7594
}

0 commit comments

Comments
 (0)