uninitStructMember: Fixed FP shown in daca@home
This commit is contained in:
parent
7a3302b3e3
commit
7ca35d181b
|
@ -1225,9 +1225,12 @@ bool CheckUninitVar::isMemberVariableUsage(const Token *tok, bool isPointer, All
|
|||
if (isMemberVariableAssignment(tok, membervar))
|
||||
return false;
|
||||
|
||||
if (Token::Match(tok, "%name% . %name%") && tok->strAt(2) == membervar && !(tok->tokAt(-2)->variable() && tok->tokAt(-2)->variable()->isReference()))
|
||||
if (Token::Match(tok, "%name% . %name%") && tok->strAt(2) == membervar && !(tok->tokAt(-2)->variable() && tok->tokAt(-2)->variable()->isReference())) {
|
||||
const Token *parent = tok->next()->astParent();
|
||||
if (parent && parent->isUnaryOp("&"))
|
||||
return false;
|
||||
return true;
|
||||
else if (!isPointer && Token::Match(tok->previous(), "[(,] %name% [,)]") && isVariableUsage(tok, isPointer, alloc))
|
||||
} else if (!isPointer && Token::Match(tok->previous(), "[(,] %name% [,)]") && isVariableUsage(tok, isPointer, alloc))
|
||||
return true;
|
||||
|
||||
else if (!isPointer && Token::Match(tok->previous(), "= %name% ;"))
|
||||
|
|
|
@ -3358,6 +3358,13 @@ private:
|
|||
"[test.cpp:5]: (error) Uninitialized struct member: abc.b\n"
|
||||
"[test.cpp:5]: (error) Uninitialized struct member: abc.c\n", errout.str());
|
||||
|
||||
checkUninitVar("struct ABC { int a; int b; int c; };\n"
|
||||
"void foo() {\n"
|
||||
" struct ABC abc;\n"
|
||||
" dostuff((uint32_t *)&abc.a);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// return
|
||||
checkUninitVar("struct AB { int a; int b; };\n"
|
||||
"void f(void) {\n"
|
||||
|
|
Loading…
Reference in New Issue