Uninitialized variables: Fix FP for struct array
This commit is contained in:
parent
66f1d9d680
commit
305760f143
|
@ -849,7 +849,7 @@ bool CheckUninitVar::isVariableUsage(const Token *vartok, bool pointer, Alloc al
|
|||
return true;
|
||||
} else if (alloc != NO_ALLOC && Token::Match(vartok, "%var% [")) {
|
||||
const Token *parent = vartok->next()->astParent();
|
||||
while (Token::simpleMatch(parent, "["))
|
||||
while (Token::Match(parent, "[|."))
|
||||
parent = parent->astParent();
|
||||
if (Token::simpleMatch(parent, "&") && !parent->astOperand2())
|
||||
return false;
|
||||
|
|
|
@ -1435,6 +1435,15 @@ private:
|
|||
" bar(x);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// struct
|
||||
checkUninitVar("struct Fred { int x; int y; };\n"
|
||||
""
|
||||
"void f() {\n"
|
||||
" struct Fred fred[10];\n"
|
||||
" fred[1].x = 0;\n"
|
||||
"}", "test.c");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar_pointertoarray() {
|
||||
|
|
Loading…
Reference in New Issue