Fixed #7758 (Function array is seen as Uninitialized)

This commit is contained in:
Daniel Marjamäki 2019-07-24 18:20:23 +02:00
parent 7c0b011c05
commit e11dcc609b
2 changed files with 13 additions and 1 deletions

View File

@ -150,7 +150,13 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
if (var.isArray()) {
Alloc alloc = ARRAY;
const std::map<int, VariableValue> variableValue;
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
bool init = false;
for (const Token *parent = var.nameToken(); parent; parent = parent->astParent()) {
if (parent->str() == "=")
init = true;
}
if (!init)
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
continue;
}
if (stdtype || var.isPointer()) {

View File

@ -4003,6 +4003,12 @@ private:
" dostuff(*a);\n"
"}");
ASSERT_EQUALS("", errout.str());
checkUninitVar("void f() {\n"
" void (*fp[1]) (void) = {function1};\n"
" (*fp[0])();\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void deadPointer() {