Fixed #7758 (Function array is seen as Uninitialized)
This commit is contained in:
parent
7c0b011c05
commit
e11dcc609b
|
@ -150,7 +150,13 @@ 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;
|
||||||
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (stdtype || var.isPointer()) {
|
if (stdtype || var.isPointer()) {
|
||||||
|
|
|
@ -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