Fix FP uninitvar when stream bool operator is used
This commit is contained in:
parent
3b68c913cb
commit
26e36a1d6b
|
@ -631,13 +631,16 @@ bool isLikelyStreamRead(bool cpp, const Token *op)
|
|||
if (!cpp)
|
||||
return false;
|
||||
|
||||
if (!Token::Match(op, "& %name% ;|&") && !Token::Match(op, ">> %name% ;|>>"))
|
||||
if (!Token::Match(op, "&|>>") || !op->astOperand2())
|
||||
return false;
|
||||
|
||||
if (!Token::Match(op->astOperand2(), "%name%|.|*|[") && op->str() != op->astOperand2()->str())
|
||||
return false;
|
||||
|
||||
const Token *parent = op;
|
||||
while (parent->astParent() && parent->astParent()->str() == op->str())
|
||||
parent = parent->astParent();
|
||||
if (parent->astParent())
|
||||
if (parent->astParent() && !Token::Match(parent->astParent(), "%oror%|&&|(|,|!"))
|
||||
return false;
|
||||
if (!parent->astOperand1() || !parent->astOperand2())
|
||||
return false;
|
||||
|
|
|
@ -2196,7 +2196,7 @@ private:
|
|||
{
|
||||
const char code[] = "void f() {\n"
|
||||
" int x;\n"
|
||||
" i >> x;\n"
|
||||
" if (i >> x) { }\n"
|
||||
"}";
|
||||
checkUninitVar(code, "test.cpp");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
|
Loading…
Reference in New Issue