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);
|
possibleParent = getAstParentSkipPossibleCastAndAddressOf(possibleParent, &unknown);
|
||||||
if (possibleParent && Token::Match(possibleParent->previous(), "decltype|sizeof ("))
|
if (possibleParent && Token::Match(possibleParent->previous(), "decltype|sizeof ("))
|
||||||
return false;
|
return false;
|
||||||
|
if (possibleParent && isLikelyStreamRead(mTokenizer->isCPP(), possibleParent))
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (Token::Match(possibleParent, "[(,]")) {
|
if (Token::Match(possibleParent, "[(,]")) {
|
||||||
if (unknown)
|
if (unknown)
|
||||||
|
|
|
@ -4690,6 +4690,15 @@ private:
|
||||||
" f(&x);\n"
|
" f(&x);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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