Fixed #5072 (False positive: comparisonOfBoolWithInvalidComparator even without explicit bool type)

This commit is contained in:
Daniel Marjamäki 2013-10-07 16:16:07 +02:00
parent a0015fc2f4
commit 023d0e7cb8
2 changed files with 4 additions and 1 deletions

View File

@ -380,7 +380,7 @@ static bool isNonBoolLHSExpr(const Token *tok)
nonBoolExpr = true; nonBoolExpr = true;
else if (tok->isArithmeticalOp()) else if (tok->isArithmeticalOp())
nonBoolExpr = true; nonBoolExpr = true;
else if (tok->str() == "!" || tok->isComparisonOp()) else if (tok->isComparisonOp() || (tok->str() == "!" && tok->previous()->str()=="("))
return false; return false;
else if (indentlevel == 0 && Token::Match(tok,"[;{}=?:&|^,]")) else if (indentlevel == 0 && Token::Match(tok,"[;{}=?:&|^,]"))
break; break;

View File

@ -306,6 +306,9 @@ private:
" if (error == ABC) { }\n" " if (error == ABC) { }\n"
"}"); "}");
ASSERT_EQUALS("", errout.str()); ASSERT_EQUALS("", errout.str());
check("int f() { return !a+b<c; }");
ASSERT_EQUALS("",errout.str());
} }
void comparisonOfBoolExpressionWithInt2() { void comparisonOfBoolExpressionWithInt2() {