Fix issue 8730: False positive: Opposite expression on both sides of && (#1366)
This commit is contained in:
parent
1d85a78874
commit
b46e25c18e
|
@ -212,6 +212,9 @@ static const Token * followVariableExpression(const Token * tok, bool cpp)
|
|||
return tok;
|
||||
if (!var2->isConst() && isVariableChanged(tok2, endToken2, tok2->varId(), false, nullptr, cpp))
|
||||
return tok;
|
||||
// Recognized as a variable but the declaration is unknown
|
||||
} else if(tok2->varId() > 0) {
|
||||
return tok;
|
||||
}
|
||||
}
|
||||
return varTok;
|
||||
|
|
|
@ -4256,6 +4256,14 @@ private:
|
|||
|
||||
check("bool f(unsigned i){ return (x > 0) && (x & (x-1)) == 0; }");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("void A::f(bool a, bool c)\n"
|
||||
"{\n"
|
||||
" const bool b = a;\n"
|
||||
" if(c) { a = false; } \n"
|
||||
" if(b && !a) { }\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void duplicateVarExpression() {
|
||||
|
|
Loading…
Reference in New Issue