Suspicious condition: Better handling when rhs is non-numeric
This commit is contained in:
parent
f62d1d0122
commit
e5ff920ea9
|
@ -152,7 +152,7 @@ void CheckOther::clarifyCondition()
|
||||||
tok2 = tok2->link();
|
tok2 = tok2->link();
|
||||||
else if (Token::Match(tok2, "&&|%oror%|?|)"))
|
else if (Token::Match(tok2, "&&|%oror%|?|)"))
|
||||||
break;
|
break;
|
||||||
else if (Token::Match(tok2, "<|<=|==|!=|>|>= %num% )"))
|
else if (Token::Match(tok2, "<|<=|==|!=|>|>="))
|
||||||
{
|
{
|
||||||
clarifyConditionError(tok, tok->strAt(2) == "=");
|
clarifyConditionError(tok, tok->strAt(2) == "=");
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -2639,6 +2639,11 @@ private:
|
||||||
" if (x & 2 == 2) {}\n"
|
" if (x & 2 == 2) {}\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious condition (bitwise operator + comparison), it can be clarified with parentheses\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious condition (bitwise operator + comparison), it can be clarified with parentheses\n", errout.str());
|
||||||
|
|
||||||
|
check("void f() {\n"
|
||||||
|
" if (a & fred1.x == fred2.y) {}\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("[test.cpp:2]: (style) Suspicious condition (bitwise operator + comparison), it can be clarified with parentheses\n", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void incorrectStringCompare()
|
void incorrectStringCompare()
|
||||||
|
|
Loading…
Reference in New Issue