Uninitialized variables; Fixed struct member access FP
This commit is contained in:
parent
c78a1dbbaf
commit
4322311482
|
@ -1023,7 +1023,7 @@ const Token* CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer,
|
|||
while (Token::Match(valueExpr->astParent(), ".|::") && astIsRhs(valueExpr))
|
||||
valueExpr = valueExpr->astParent();
|
||||
if (!pointer) {
|
||||
if (Token::Match(vartok, "%name% [.(]") && vartok->variable() && !vartok->variable()->isPointer() && vartok->variable()->isClass())
|
||||
if (Token::Match(vartok, "%name% [.(]") && vartok->variable() && !vartok->variable()->isPointer())
|
||||
return nullptr;
|
||||
while (Token::simpleMatch(valueExpr->astParent(), ".") && astIsLhs(valueExpr) && valueExpr->astParent()->valueType() && valueExpr->astParent()->valueType()->pointer == 0)
|
||||
valueExpr = valueExpr->astParent();
|
||||
|
|
|
@ -3590,6 +3590,12 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
checkUninitVar("void f(void) {\n"
|
||||
" struct tm t;\n"
|
||||
" t.tm_year = 123;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// return
|
||||
checkUninitVar("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
|
@ -4279,6 +4285,7 @@ private:
|
|||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// struct
|
||||
valueFlowUninit("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
" AB ab;\n"
|
||||
|
|
Loading…
Reference in New Issue