File tree Expand file tree Collapse file tree
test/query-tests/Likely Bugs/ContinueInFalseLoop Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1010
1111import cpp
1212
13- Loop getAFalseLoop ( ) {
13+ DoStmt getAFalseLoop ( ) {
1414 result .getControllingExpr ( ) .getValue ( ) = "0"
1515 and not result .getControllingExpr ( ) .isAffectedByMacro ( )
1616}
1717
18- Loop enclosingLoop ( Stmt s ) {
18+ DoStmt enclosingLoop ( Stmt s ) {
1919 exists ( Stmt parent |
2020 parent = s .getParent ( ) and
2121 if parent instanceof Loop then
@@ -24,7 +24,7 @@ Loop enclosingLoop(Stmt s) {
2424 result = enclosingLoop ( parent ) )
2525}
2626
27- from Loop loop , ContinueStmt continue
27+ from DoStmt loop , ContinueStmt continue
2828where loop = getAFalseLoop ( )
2929 and loop = enclosingLoop ( continue )
3030select continue ,
Original file line number Diff line number Diff line change 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 |
2- | test.cpp:39:4:39:12 | continue; | This 'continue' never re-runs the loop - the $@ is always false. | test.cpp:36:9:36:13 | 0 | loop condition |
3- | test.cpp:47:4:47:12 | continue; | This 'continue' never re-runs the loop - the $@ is always false. | test.cpp:44:14:44:18 | 0 | loop condition |
42| 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 |
Original file line number Diff line number Diff line change @@ -36,15 +36,15 @@ void test1()
3636 while (false )
3737 {
3838 if (cond ())
39- continue ; // GOOD [never reached, if the condition changed so it was then the result would no longer apply] [FALSE POSITIVE]
39+ continue ; // GOOD [never reached, if the condition changed so it was then the result would no longer apply]
4040 if (cond ())
4141 break ;
4242 }
4343
4444 for (i = 0 ; false ; i++)
4545 {
4646 if (cond ())
47- continue ; // GOOD [never reached, if the condition changed so it was then the result would no longer apply] [FALSE POSITIVE]
47+ continue ; // GOOD [never reached, if the condition changed so it was then the result would no longer apply]
4848 if (cond ())
4949 break ;
5050 }
You can’t perform that action at this time.
0 commit comments