Fixed clarifyCalculation fp for 'a % b ? "a" : "b"'. seen in daca@home.
This commit is contained in:
parent
4e4108dc8b
commit
e32ccb591b
|
@ -160,8 +160,8 @@ void CheckOther::clarifyCalculation()
|
||||||
if (!tok->astOperand1()->isArithmeticalOp() && tok->astOperand1()->tokType() != Token::eBitOp)
|
if (!tok->astOperand1()->isArithmeticalOp() && tok->astOperand1()->tokType() != Token::eBitOp)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// bit operation in lhs and pointer in rhs => no clarification is needed
|
// non-pointer calculation in lhs and pointer in rhs => no clarification is needed
|
||||||
if (tok->astOperand1()->tokType() == Token::eBitOp && tok->astOperand2()->valueType() && tok->astOperand2()->valueType()->pointer > 0)
|
if (tok->astOperand1()->isBinaryOp() && Token::Match(tok->astOperand1(), "%or%|&|%|*|/") && tok->astOperand2()->valueType() && tok->astOperand2()->valueType()->pointer > 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// bit operation in lhs and char literals in rhs => probably no mistake
|
// bit operation in lhs and char literals in rhs => probably no mistake
|
||||||
|
|
|
@ -4272,6 +4272,9 @@ private:
|
||||||
check("void f(int x) { const char *p = x & 1 ? \"1\" : \"0\"; }");
|
check("void f(int x) { const char *p = x & 1 ? \"1\" : \"0\"; }");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void foo() { x = a % b ? \"1\" : \"0\"; }");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
check("void f(int x) { return x & 1 ? '1' : '0'; }");
|
check("void f(int x) { return x & 1 ? '1' : '0'; }");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue