UninitVar: Don't warn for inconclusive values
This commit is contained in:
parent
a0a8f8ddd6
commit
06102cb3d7
|
@ -1208,13 +1208,14 @@ void CheckUninitVar::valueFlowUninit()
|
|||
if (!scope->isExecutable())
|
||||
continue;
|
||||
for (const Token* tok = scope->classStart; tok != scope->classEnd; tok = tok->next()) {
|
||||
if (!tok->variable())
|
||||
if (!tok->variable() || tok->values().size() != 1U)
|
||||
continue;
|
||||
if (tok->values().size() != 1U || tok->values().front().valueType != ValueFlow::Value::UNINIT)
|
||||
const ValueFlow::Value &v = tok->values().front();
|
||||
if (v.valueType != ValueFlow::Value::UNINIT || v.inconclusive)
|
||||
continue;
|
||||
if (!isVariableUsage(tok, tok->variable()->isPointer(), NO_ALLOC))
|
||||
continue;
|
||||
uninitvarError(tok,tok->str());
|
||||
uninitvarError(tok, tok->str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3816,6 +3816,13 @@ private:
|
|||
" switch (x) {}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: x\n", errout.str());
|
||||
|
||||
checkUninitVar("int f() {\n"
|
||||
" int x;\n"
|
||||
" init(x);\n"
|
||||
" return x;\n" // TODO: inconclusive ?
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void isVariableUsageDeref() {
|
||||
|
|
Loading…
Reference in New Issue