Fixed #7758 (Function array is seen as Uninitialized)
This commit is contained in:
parent
7c0b011c05
commit
e11dcc609b
|
@ -150,6 +150,12 @@ void CheckUninitVar::checkScope(const Scope* scope, const std::set<std::string>
|
||||||
if (var.isArray()) {
|
if (var.isArray()) {
|
||||||
Alloc alloc = ARRAY;
|
Alloc alloc = ARRAY;
|
||||||
const std::map<int, VariableValue> variableValue;
|
const std::map<int, VariableValue> 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);
|
checkScopeForVariable(tok, var, nullptr, nullptr, &alloc, emptyString, variableValue);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4003,6 +4003,12 @@ private:
|
||||||
" dostuff(*a);\n"
|
" dostuff(*a);\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
checkUninitVar("void f() {\n"
|
||||||
|
" void (*fp[1]) (void) = {function1};\n"
|
||||||
|
" (*fp[0])();\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void deadPointer() {
|
void deadPointer() {
|
||||||
|
|
Loading…
Reference in New Issue