Fixed #8412 (ignoredReturnValue not issued when return value is changed but not really used (by logical not for example))
This commit is contained in:
parent
44f914eaee
commit
518fb01553
|
@ -204,7 +204,10 @@ void CheckFunctions::checkIgnoredReturnValue()
|
|||
if (tok->varId() || !Token::Match(tok, "%name% (") || tok->isKeyword())
|
||||
continue;
|
||||
|
||||
if (tok->next()->astParent())
|
||||
const Token *parent = tok->next()->astParent();
|
||||
while (Token::Match(parent, "%cop%"))
|
||||
parent = parent->astParent();
|
||||
if (parent)
|
||||
continue;
|
||||
|
||||
if (!tok->scope()->isExecutable()) {
|
||||
|
|
|
@ -1231,6 +1231,13 @@ private:
|
|||
"}\n"
|
||||
"A g() { return f(1); }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #8412 - unused operator result
|
||||
check("void foo() {\n"
|
||||
" !mystrcmp(a, b);\n"
|
||||
"}", "test.cpp", &settings2);
|
||||
ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of function mystrcmp() is not used.\n", errout.str());
|
||||
|
||||
}
|
||||
|
||||
void checkIgnoredErrorCode() {
|
||||
|
|
Loading…
Reference in New Issue