Fixed #3497 (False positive: Uninitialized variable)
This commit is contained in:
parent
36479499e7
commit
b8faee9d30
|
@ -474,7 +474,13 @@ private:
|
||||||
if (tok.varId()) {
|
if (tok.varId()) {
|
||||||
// array variable passed as function parameter..
|
// array variable passed as function parameter..
|
||||||
if (Token::Match(tok.previous(), "[(,] %var% [+-,)]")) {
|
if (Token::Match(tok.previous(), "[(,] %var% [+-,)]")) {
|
||||||
if (Token::Match(tok.previous(), "( %var% ) )| ="))
|
// skip ')'..
|
||||||
|
const Token *tok2 = tok.next();
|
||||||
|
while (tok2 && tok2->str() == ")")
|
||||||
|
tok2 = tok2->next();
|
||||||
|
|
||||||
|
// variable is assigned like: "( %var% ) .. ="
|
||||||
|
if (Token::Match(tok.previous(), "( %var% )") && tok2 && tok2->str() == "=")
|
||||||
ExecutionPath::bailOutVar(checks, tok.varId());
|
ExecutionPath::bailOutVar(checks, tok.varId());
|
||||||
else
|
else
|
||||||
use(checks, &tok);
|
use(checks, &tok);
|
||||||
|
|
|
@ -1139,6 +1139,13 @@ private:
|
||||||
" return header[0];\n"
|
" return header[0];\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void f() {\n" // Ticket #3497
|
||||||
|
" char header[1];\n"
|
||||||
|
" *((unsigned char*)((unsigned char *)(header))) = 0xff;\n"
|
||||||
|
" return header[0];\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// alloc..
|
// alloc..
|
||||||
|
|
Loading…
Reference in New Issue