Uninitialized variables: fixed FP when there are suspicious function calls where type** is converted to type*

This commit is contained in:
Daniel Marjamäki 2012-12-25 13:58:15 +01:00
parent bcc5a82b1d
commit f381058293
2 changed files with 8 additions and 1 deletions

View File

@ -1382,7 +1382,7 @@ bool CheckUninitVar::isVariableUsage(const Scope* scope, const Token *vartok, bo
return true;
if (Token::Match(argStart, "const %type% & %var% [,)]"))
return true;
if (pointer && Token::Match(argStart, "%type% * %var% [,)]"))
if (pointer && !address && Token::Match(argStart, "%type% * %var% [,)]"))
return true;
if ((pointer || address) && Token::Match(argStart, "const %type% * %var% [,)]"))
return true;

View File

@ -2452,6 +2452,13 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar2("void a(char *c);\n" // address of pointer (suspicious cast to pointer) => no error
"void b() {\n"
" char *c;\n"
" a(&c);\n"
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar2("void a(const char **c);\n" // const address of pointer => no error
"void b() {\n"
" const char *c;\n"