Fixed false positive in new 'x>-1<5' check when using templates
This commit is contained in:
parent
0d246f84ca
commit
51ad747317
|
@ -410,6 +410,9 @@ void CheckBool::checkComparisonOfBoolExpressionWithInt()
|
|||
break;
|
||||
}
|
||||
if (Token::Match(lhs,"<|<=|>|>=")) {
|
||||
if (_tokenizer->isCPP() && tok->str() == ">" &&
|
||||
(Token::Match(lhs->previous(), "%var% <") || lhs->str() == ">"))
|
||||
continue;
|
||||
while (NULL != (lhs = lhs->previous())) {
|
||||
if ((lhs->isName() && lhs->str() != "return") || lhs->isNumber())
|
||||
continue;
|
||||
|
|
|
@ -353,6 +353,13 @@ private:
|
|||
" for(int i = 4; i > -1 < 5 ; --i) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (warning) Comparison of a boolean value using relational operator (<, >, <= or >=).\n", errout.str());
|
||||
|
||||
// templates
|
||||
check("struct Tokenizer { TokenList list; };\n"
|
||||
"void Tokenizer::f() {\n"
|
||||
" std::list<Token*> locationList;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void checkComparisonOfFuncReturningBool1() {
|
||||
|
|
Loading…
Reference in New Issue