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;
|
return true;
|
||||||
} else if (alloc != NO_ALLOC && Token::Match(vartok, "%var% [")) {
|
} else if (alloc != NO_ALLOC && Token::Match(vartok, "%var% [")) {
|
||||||
const Token *parent = vartok->next()->astParent();
|
const Token *parent = vartok->next()->astParent();
|
||||||
while (Token::simpleMatch(parent, "["))
|
while (Token::Match(parent, "[|."))
|
||||||
parent = parent->astParent();
|
parent = parent->astParent();
|
||||||
if (Token::simpleMatch(parent, "&") && !parent->astOperand2())
|
if (Token::simpleMatch(parent, "&") && !parent->astOperand2())
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -1435,6 +1435,15 @@ private:
|
||||||
" bar(x);\n"
|
" bar(x);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
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() {
|
void uninitvar_pointertoarray() {
|
||||||
|
|
Loading…
Reference in New Issue