uninitvar: Fixed a FP seen in daca2
This commit is contained in:
parent
ecc91ba914
commit
c8a450c9be
|
@ -839,7 +839,8 @@ void CheckUninitVar::checkRhs(const Token *tok, const Variable &var, Alloc alloc
|
||||||
uninitvarError(tok, tok->str(), alloc);
|
uninitvarError(tok, tok->str(), alloc);
|
||||||
else if (!membervar.empty() && isMemberVariableUsage(tok, var.isPointer(), alloc, membervar))
|
else if (!membervar.empty() && isMemberVariableUsage(tok, var.isPointer(), alloc, membervar))
|
||||||
uninitStructMemberError(tok, tok->str() + "." + membervar);
|
uninitStructMemberError(tok, tok->str() + "." + membervar);
|
||||||
|
else if (Token::Match(tok, "%var% ="))
|
||||||
|
break;
|
||||||
} else if (tok->str() == ";" || (indent==0 && tok->str() == ","))
|
} else if (tok->str() == ";" || (indent==0 && tok->str() == ","))
|
||||||
break;
|
break;
|
||||||
else if (tok->str() == "(")
|
else if (tok->str() == "(")
|
||||||
|
|
|
@ -969,6 +969,11 @@ private:
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: y\n", errout.str());
|
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: y\n", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void foo() {\n" // pidgin-2.11.0/finch/libgnt/gnttree.c
|
||||||
|
" int x = (x = bar()) ? x : 0;\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
// ; { .. }
|
// ; { .. }
|
||||||
checkUninitVar("int foo()\n"
|
checkUninitVar("int foo()\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue