parent
b4df064875
commit
1bc0317719
|
@ -1461,7 +1461,7 @@ bool CheckUninitVar::isMemberVariableUsage(const Token *tok, bool isPointer, All
|
||||||
if (parent && parent->isUnaryOp("&"))
|
if (parent && parent->isUnaryOp("&"))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
} else if (!isPointer && Token::Match(tok->previous(), "[(,] %name% [,)]") && isVariableUsage(tok, isPointer, alloc))
|
} else if (!isPointer && !Token::simpleMatch(tok->astParent(), ".") && Token::Match(tok->previous(), "[(,] %name% [,)]") && isVariableUsage(tok, isPointer, alloc))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
else if (!isPointer && Token::Match(tok->previous(), "= %name% ;"))
|
else if (!isPointer && Token::Match(tok->previous(), "= %name% ;"))
|
||||||
|
|
|
@ -4132,6 +4132,15 @@ private:
|
||||||
" x = a.m;\n"
|
" x = a.m;\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #11002
|
||||||
|
checkUninitVar("struct S { char *p; int len; };\n"
|
||||||
|
"void f() {\n"
|
||||||
|
" S s;\n"
|
||||||
|
" s.p = nullptr;\n"
|
||||||
|
" char* q = (s).p;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar2_while() {
|
void uninitvar2_while() {
|
||||||
|
|
Loading…
Reference in New Issue