This commit is contained in:
parent
285ef96b5b
commit
09f426d980
|
@ -3249,9 +3249,11 @@ static ExprUsage getFunctionUsage(const Token* tok, int indirect, const Settings
|
|||
|
||||
ExprUsage getExprUsage(const Token* tok, int indirect, const Settings* settings, bool cpp)
|
||||
{
|
||||
const Token* const parent = tok->astParent();
|
||||
const Token* parent = tok->astParent();
|
||||
if (indirect > 0 && parent) {
|
||||
if (Token::Match(parent, "%assign%") && astIsRHS(tok))
|
||||
while (Token::simpleMatch(parent, "[") && parent->astParent())
|
||||
parent = parent->astParent();
|
||||
if (Token::Match(parent, "%assign%") && (astIsRHS(tok) || astIsLHS(parent->astOperand1())))
|
||||
return ExprUsage::NotUsed;
|
||||
if (parent->isConstOp())
|
||||
return ExprUsage::NotUsed;
|
||||
|
|
|
@ -6289,6 +6289,14 @@ private:
|
|||
" foo(q);\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("[test.cpp:9]: (error) Uninitialized variable: q\n", errout.str());
|
||||
|
||||
valueFlowUninit("int g();\n" // #12082
|
||||
"void f() {\n"
|
||||
" int a[1], b[1];\n"
|
||||
" while (a[0] = g()) {}\n"
|
||||
" if ((b[0] = g()) == 0) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void valueFlowUninitBreak() { // Do not show duplicate warnings about the same uninitialized value
|
||||
|
|
Loading…
Reference in New Issue