Fixed #3497 (False positive: Uninitialized variable)
This commit is contained in:
parent
e43fa83aa4
commit
47716ee4ca
|
@ -474,7 +474,7 @@ private:
|
|||
if (tok.varId()) {
|
||||
// array variable passed as function parameter..
|
||||
if (Token::Match(tok.previous(), "[(,] %var% [+-,)]")) {
|
||||
if (Token::Match(tok.previous(), "( %var% ) ="))
|
||||
if (Token::Match(tok.previous(), "( %var% ) )| ="))
|
||||
ExecutionPath::bailOutVar(checks, tok.varId());
|
||||
else
|
||||
use(checks, &tok);
|
||||
|
|
|
@ -1132,6 +1132,13 @@ private:
|
|||
" printf(\"%s\", a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("[test.cpp:3]: (error) Uninitialized variable: a\n", errout.str());
|
||||
|
||||
checkUninitVar("void f() {\n" // Ticket #3497
|
||||
" char header[1];\n"
|
||||
" *((unsigned char*)(header)) = 0xff;\n"
|
||||
" return header[0];\n"
|
||||
"}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
// alloc..
|
||||
|
|
Loading…
Reference in New Issue