Fixed #9349 (FP ctuuninitvar for pointer dereferenced inside sizeof)
This commit is contained in:
parent
b8e3d3b982
commit
da363c7d6f
|
@ -979,6 +979,12 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
|
|||
{
|
||||
bool unknown = false;
|
||||
const Token *possibleParent = getAstParentSkipPossibleCastAndAddressOf(vartok, &unknown);
|
||||
if (possibleParent && possibleParent->isUnaryOp("*")) {
|
||||
while (possibleParent && possibleParent->isUnaryOp("*"))
|
||||
possibleParent = getAstParentSkipPossibleCastAndAddressOf(possibleParent, &unknown);
|
||||
if (possibleParent && Token::Match(possibleParent->previous(), "sizeof ("))
|
||||
return false;
|
||||
}
|
||||
if (Token::Match(possibleParent, "[(,]")) {
|
||||
if (unknown)
|
||||
return false; // TODO: output some info message?
|
||||
|
|
|
@ -4583,6 +4583,14 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
ctu("void f(int *p) {\n"
|
||||
" a = sizeof(*p);\n"
|
||||
"}\n"
|
||||
"int main() {\n"
|
||||
" int x;\n"
|
||||
" f(&x);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue