Fixed #4431 (FP: Erroneous 'Ineffective call of function empty()' in ?: test)
This commit is contained in:
parent
299c1bb208
commit
db123c2c9b
@ -1408,7 +1408,7 @@ void CheckStl::uselessCalls()
|
|||||||
uselessCallsSubstrError(tok, false);
|
uselessCallsSubstrError(tok, false);
|
||||||
} else if (Token::simpleMatch(tok->linkAt(2)->tokAt(-2), ", 0 )"))
|
} else if (Token::simpleMatch(tok->linkAt(2)->tokAt(-2), ", 0 )"))
|
||||||
uselessCallsSubstrError(tok, true);
|
uselessCallsSubstrError(tok, true);
|
||||||
} else if (Token::Match(tok, "[{}:;] %var% . empty ( ) ;") && style)
|
} else if (Token::Match(tok, "[{};] %var% . empty ( ) ;") && style)
|
||||||
uselessCallsEmptyError(tok->next());
|
uselessCallsEmptyError(tok->next());
|
||||||
else if (Token::Match(tok, "[{};] std :: remove|remove_if|unique (") && tok->tokAt(5)->nextArgument())
|
else if (Token::Match(tok, "[{};] std :: remove|remove_if|unique (") && tok->tokAt(5)->nextArgument())
|
||||||
uselessCallsRemoveError(tok->next(), tok->strAt(3));
|
uselessCallsRemoveError(tok->next(), tok->strAt(3));
|
||||||
|
@ -2124,6 +2124,12 @@ private:
|
|||||||
ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n"
|
ASSERT_EQUALS("[test.cpp:2]: (warning) Return value of std::remove() ignored. Elements remain in container.\n"
|
||||||
"[test.cpp:3]: (warning) Return value of std::remove_if() ignored. Elements remain in container.\n"
|
"[test.cpp:3]: (warning) Return value of std::remove_if() ignored. Elements remain in container.\n"
|
||||||
"[test.cpp:4]: (warning) Return value of std::unique() ignored. Elements remain in container.\n", errout.str());
|
"[test.cpp:4]: (warning) Return value of std::unique() ignored. Elements remain in container.\n", errout.str());
|
||||||
|
|
||||||
|
// #4431 - fp
|
||||||
|
check("bool f() {\n"
|
||||||
|
" return x ? true : (y.empty());\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user