Fixed false positive when noreturn function is defined (#5601)
This commit is contained in:
parent
94476e387e
commit
77c871035b
|
@ -1591,7 +1591,7 @@ void CheckOther::checkUnreachableCode()
|
|||
for (const Token *tok = _tokenizer->tokens(); tok; tok = tok->next()) {
|
||||
const Token* secondBreak = 0;
|
||||
const Token* labelName = 0;
|
||||
if (tok->str() == "(")
|
||||
if (tok->link() && Token::Match(tok, "(|[|<"))
|
||||
tok = tok->link();
|
||||
else if (Token::Match(tok, "break|continue ;"))
|
||||
secondBreak = tok->tokAt(2);
|
||||
|
@ -1609,7 +1609,8 @@ void CheckOther::checkUnreachableCode()
|
|||
secondBreak = tok->tokAt(3);
|
||||
labelName = tok->next();
|
||||
} else if (Token::Match(tok, "%var% (") && _settings->library.isnoreturn(tok->str())) {
|
||||
secondBreak = tok->linkAt(1)->tokAt(2);
|
||||
if (!tok->function() || (tok->function()->token != tok && tok->function()->tokenDef != tok))
|
||||
secondBreak = tok->linkAt(1)->tokAt(2);
|
||||
}
|
||||
|
||||
// Statements follow directly, no line between them. (#3383)
|
||||
|
|
|
@ -2862,6 +2862,15 @@ private:
|
|||
"}", 0, false, false, false, false, &settings);
|
||||
ASSERT_EQUALS("[test.cpp:3]: (style) Consecutive return, break, continue, goto or throw statements are unnecessary.\n", errout.str());
|
||||
|
||||
check("class NeonSession {\n"
|
||||
" void exit();\n"
|
||||
"};\n"
|
||||
"void NeonSession::exit()\n"
|
||||
"{\n"
|
||||
" SAL_INFO(\"ucb.ucp.webdav\", \"neon commands cannot be aborted\");\n"
|
||||
"}", 0, false, false, false, false, &settings);
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void foo(int a)\n"
|
||||
"{\n"
|
||||
" switch(a) {\n"
|
||||
|
|
Loading…
Reference in New Issue