Fixed #3676.
This commit is contained in:
parent
8492685531
commit
033e4a2c1f
|
@ -1164,6 +1164,9 @@ void CheckOther::checkIncorrectLogicOperator()
|
|||
if (conditions[i].after != 0 && !Token::Match(nextTok, conditions[i].after))
|
||||
continue;
|
||||
|
||||
if (tok->previous()->isArithmeticalOp() || nextTok->isArithmeticalOp())
|
||||
continue;
|
||||
|
||||
std::string cond1str = var1Tok->str() + " " + (varFirst1?op1Tok->str():invertOperatorForOperandSwap(op1Tok->str())) + " " + firstConstant;
|
||||
std::string cond2str = var2Tok->str() + " " + (varFirst2?op3Tok->str():invertOperatorForOperandSwap(op3Tok->str())) + " " + secondConstant;
|
||||
// cond1 op cond2
|
||||
|
|
|
@ -2888,6 +2888,13 @@ private:
|
|||
" if ( &q != &a && &q != &b ) { }\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// #3676
|
||||
check("void f(int m_x2, int w, int x) {\n"
|
||||
" if (x + w - 1 > m_x2 || m_x2 < 0 )\n"
|
||||
" m_x2 = x + w - 1;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void incorrectLogicOperator3() {
|
||||
|
|
Loading…
Reference in New Issue