Skip to content

Commit e3696fc

Browse files
Fix #13475 FP unreachableCode for empty statement (danmar#7136)
1 parent e427162 commit e3696fc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

lib/checkother.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ void CheckOther::checkUnreachableCode()
903903
}
904904
while (Token::simpleMatch(secondBreak, "}") && secondBreak->scope()->type == Scope::ScopeType::eUnconditional)
905905
secondBreak = secondBreak->next();
906+
if (Token::simpleMatch(secondBreak, ";"))
907+
continue;
906908

907909
// Statements follow directly, no line between them. (#3383)
908910
// TODO: Try to find a better way to avoid false positives due to preprocessor configurations.

test/testother.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5644,6 +5644,11 @@ class TestOther : public TestFixture {
56445644
" } while (i < 10);\n"
56455645
"}\n");
56465646
ASSERT_EQUALS("[test.cpp:5]: (style) 'continue' is redundant since it is the last statement in a loop.\n", errout_str());
5647+
5648+
check("int f() {\n" // #13475
5649+
" { return 0; };\n"
5650+
"}\n");
5651+
ASSERT_EQUALS("", errout_str());
56475652
}
56485653

56495654

0 commit comments

Comments
 (0)