File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -887,8 +887,6 @@ void CheckOther::checkUnreachableCode()
887887 tok2 = tok2->link ();
888888 if (tok2->str () == " ;" ) {
889889 secondBreak = tok2->next ();
890- while (Token::simpleMatch (secondBreak, " }" ) && secondBreak->scope ()->type == Scope::ScopeType::eUnconditional)
891- secondBreak = secondBreak->next ();
892890 break ;
893891 }
894892 }
@@ -903,6 +901,8 @@ void CheckOther::checkUnreachableCode()
903901 continue ;
904902 }
905903 }
904+ while (Token::simpleMatch (secondBreak, " }" ) && secondBreak->scope ()->type == Scope::ScopeType::eUnconditional)
905+ secondBreak = secondBreak->next ();
906906
907907 // Statements follow directly, no line between them. (#3383)
908908 // TODO: Try to find a better way to avoid false positives due to preprocessor configurations.
Original file line number Diff line number Diff line change @@ -5615,6 +5615,15 @@ class TestOther : public TestFixture {
56155615 " std::cout << \" y\" ;\n "
56165616 " }\n " );
56175617 ASSERT_EQUALS (" [test.cpp:6]: (style) Statements following 'return' will never be executed.\n " , errout_str ());
5618+
5619+ check (" void f() {\n "
5620+ " {\n "
5621+ " std::cout << \" x\" ;\n "
5622+ " exit(1);\n "
5623+ " }\n "
5624+ " std::cout << \" y\" ;\n "
5625+ " }\n " );
5626+ ASSERT_EQUALS (" [test.cpp:6]: (style) Statements following noreturn function 'exit()' will never be executed.\n " , errout_str ());
56185627 }
56195628
56205629 void redundantContinue () {
You can’t perform that action at this time.
0 commit comments