Fixed #9933 (FP: uninitvar when reading to struct)
This commit is contained in:
parent
2ae91b9ffe
commit
4330a43acb
|
@ -1368,6 +1368,8 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn)
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
while (parent && parent->isCast())
|
while (parent && parent->isCast())
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
|
if (Token::Match(parent, "[+-]") && parent->valueType() && parent->valueType()->pointer)
|
||||||
|
parent = parent->astParent();
|
||||||
|
|
||||||
// passing variable to subfunction?
|
// passing variable to subfunction?
|
||||||
if (Token::Match(parent, "[(,{]"))
|
if (Token::Match(parent, "[(,{]"))
|
||||||
|
|
|
@ -4109,6 +4109,17 @@ private:
|
||||||
"}";
|
"}";
|
||||||
values = tokenValues(code, "szHdr ; }");
|
values = tokenValues(code, "szHdr ; }");
|
||||||
ASSERT_EQUALS(0, values.size());
|
ASSERT_EQUALS(0, values.size());
|
||||||
|
|
||||||
|
// #9933
|
||||||
|
code = "struct MyStruct { size_t value; }\n"
|
||||||
|
"\n"
|
||||||
|
"void foo() {\n"
|
||||||
|
" MyStruct x;\n"
|
||||||
|
" fread(((char *)&x) + 0, sizeof(x), f);\n"
|
||||||
|
" if (x.value < 432) {}\n"
|
||||||
|
"}";
|
||||||
|
values = tokenValues(code, "x . value");
|
||||||
|
ASSERT_EQUALS(0, values.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
void valueFlowTerminatingCond() {
|
void valueFlowTerminatingCond() {
|
||||||
|
|
Loading…
Reference in New Issue