Fixed #3586 (false positive: uninitvar in argument in namespaced function)

This commit is contained in:
Daniel Marjamäki 2012-09-15 10:48:17 +02:00
parent b4d78e3d05
commit 84c0368bfd
2 changed files with 10 additions and 4 deletions

View File

@ -474,7 +474,7 @@ private:
// variable is assigned like: "( %var% ) .. ="
if (Token::Match(tok.previous(), "( %var% )") && tok2 && tok2->str() == "=")
ExecutionPath::bailOutVar(checks, tok.varId());
else
else if (!(tok.strAt(-2) == ">" && tok.tokAt(-2)->link()))
use(checks, &tok);
//use_array(checks, &tok);
return &tok;

View File

@ -864,14 +864,14 @@ private:
checkUninitVar("void f()\n"
"{\n"
" char *c1;\n"
" c1=strcpy(c1,\"test\");\n"
" char *c1;\n"
" c1=strcpy(c1,\"test\");\n"
"}\n");
TODO_ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: c1\n","", errout.str());
checkUninitVar("void f(char *c1)\n"
"{\n"
" c1=strcpy(c1,\"test\");\n"
" c1=strcpy(c1,\"test\");\n"
"}\n");
ASSERT_EQUALS("", errout.str());
@ -1777,6 +1777,12 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n" // #3586 - calling template function
" int i;\n"
" a::b<int>(i);\n"
"}\n");
ASSERT_EQUALS("", errout.str());
// using uninitialized function pointer..
checkUninitVar("void foo()\n"
"{\n"