File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -887,6 +887,8 @@ 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 ();
890892 break ;
891893 }
892894 }
Original file line number Diff line number Diff line change @@ -5606,6 +5606,15 @@ class TestOther : public TestFixture {
56065606 " } while (0);\n "
56075607 " }\n " );
56085608 ASSERT_EQUALS (" [test.cpp:4]: (style) Statements following 'break' will never be executed.\n " , errout_str ());
5609+
5610+ check (" void f() {\n " // #12244
5611+ " {\n "
5612+ " std::cout << \" x\" ;\n "
5613+ " return;\n "
5614+ " }\n "
5615+ " std::cout << \" y\" ;\n "
5616+ " }\n " );
5617+ ASSERT_EQUALS (" [test.cpp:6]: (style) Statements following 'return' will never be executed.\n " , errout_str ());
56095618 }
56105619
56115620 void redundantContinue () {
You can’t perform that action at this time.
0 commit comments