diff --git a/lib/checkother.cpp b/lib/checkother.cpp index e0e8c07d1..14b64fe70 100644 --- a/lib/checkother.cpp +++ b/lib/checkother.cpp @@ -802,6 +802,10 @@ void CheckOther::checkUnreachableCode() } else if (Token::Match(tok, "%name% (") && mSettings->library.isnoreturn(tok) && !Token::Match(tok->next()->astParent(), "?|:")) { if ((!tok->function() || (tok->function()->token != tok && tok->function()->tokenDef != tok)) && tok->linkAt(1)->strAt(1) != "{") secondBreak = tok->linkAt(1)->tokAt(2); + if (Token::simpleMatch(secondBreak, "return")) { + // clarification for tools that function returns + continue; + } } // Statements follow directly, no line between them. (#3383) diff --git a/test/testother.cpp b/test/testother.cpp index 38eb28cd0..274890f02 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3772,6 +3772,12 @@ private: " bar();\n" "}", nullptr, false, false, false, false, &settings), InternalError); //ASSERT_EQUALS("", errout.str()); + + check("int foo() {\n" + " exit(0);\n" + " return 1;\n" // <- clarify for tools that function does not continue.. + "}"); + ASSERT_EQUALS("", errout.str()); }