duplicateBreak; Allow extra return that clarifies for tool(s) that function does not continue
This commit is contained in:
parent
a2cb9f17c1
commit
1783fd1bba
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue