Fixed #9594 (False positive: Using argument that points at uninitialized variable when write only)
This commit is contained in:
parent
c8df734c07
commit
ca3095746c
|
@ -990,6 +990,8 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
|
|||
possibleParent = getAstParentSkipPossibleCastAndAddressOf(possibleParent, &unknown);
|
||||
if (possibleParent && Token::Match(possibleParent->previous(), "decltype|sizeof ("))
|
||||
return false;
|
||||
if (possibleParent && isLikelyStreamRead(mTokenizer->isCPP(), possibleParent))
|
||||
return false;
|
||||
}
|
||||
if (Token::Match(possibleParent, "[(,]")) {
|
||||
if (unknown)
|
||||
|
@ -1401,7 +1403,7 @@ Check::FileInfo *CheckUninitVar::getFileInfo() const
|
|||
return nullptr;
|
||||
|
||||
MyFileInfo *fileInfo = new MyFileInfo;
|
||||
fileInfo->unsafeUsage = unsafeUsage ;
|
||||
fileInfo->unsafeUsage = unsafeUsage;
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -4690,6 +4690,15 @@ private:
|
|||
" f(&x);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
ctu("void f(int *v) {\n"
|
||||
" std::cin >> *v;\n"
|
||||
"}\n"
|
||||
"int main() {\n"
|
||||
" int x;\n"
|
||||
" f(&x);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue