Uninitialized variables : fixed false positives when passing address of pointer to function.
This commit is contained in:
parent
3bd08552ab
commit
415ee977d8
|
@ -1311,7 +1311,7 @@ bool CheckUninitVar::isVariableUsage(const Scope* scope, const Token *vartok, bo
|
|||
argStart = argStart->previous();
|
||||
if (argStart->isStandardType() && Token::Match(argStart, "%type% %var% [,)]"))
|
||||
return true;
|
||||
if (Token::Match(argStart, "const"))
|
||||
if (!(pointer && address) && Token::Match(argStart, "const"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2375,7 +2375,7 @@ private:
|
|||
ASSERT_EQUALS("[test.c:3]: (error) Uninitialized variable: a\n", errout.str());
|
||||
}
|
||||
|
||||
// Handling of unknown types. Assume they are POD in C.
|
||||
// Handling of function calls
|
||||
void uninitvar2_func() {
|
||||
checkUninitVar2("void a(char c);\n"
|
||||
"void b() {\n"
|
||||
|
@ -2411,6 +2411,13 @@ private:
|
|||
" a(&abc);\n"
|
||||
"}", "test.c");
|
||||
ASSERT_EQUALS("[test.c:4]: (error) Uninitialized variable: abc\n", errout.str());
|
||||
|
||||
checkUninitVar2("void a(const char **p);\n"
|
||||
"void b() {\n"
|
||||
" const char *s;\n"
|
||||
" a(&s);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue