CheckUninitVar: Fix a FP reported for invalid code

This commit is contained in:
Daniel Marjamäki 2015-07-22 21:58:06 +02:00
parent 42ed436e9d
commit 1f5eea98b5
2 changed files with 8 additions and 1 deletions

View File

@ -1916,7 +1916,7 @@ int CheckUninitVar::isFunctionParUsage(const Token *vartok, bool pointer, Alloc
return alloc == NO_ALLOC;
} else {
const bool isnullbad = _settings->library.isnullargbad(start->previous(), argumentNumber + 1);
if (!address && isnullbad && alloc == NO_ALLOC)
if (pointer && !address && isnullbad && alloc == NO_ALLOC)
return true;
const bool isuninitbad = _settings->library.isuninitargbad(start->previous(), argumentNumber + 1);
if (alloc != NO_ALLOC)

View File

@ -1012,6 +1012,13 @@ private:
"}");
ASSERT_EQUALS("", errout.str());
// TODO: write a proper testcase, this can not be compiled
checkUninitVar2("struct X { int x; };\n"
"void f() {\n"
" X var;\n"
" memset(var, 0, sizeof(var));\n"
"}");
ASSERT_EQUALS("", errout.str());
}