Uninitialized variables: Fixed false positive when taking address of uninitialized array that is a struct member
This commit is contained in:
parent
1b9c1c03fa
commit
a79354d51c
|
@ -1092,8 +1092,11 @@ void CheckUninitVar::checkScope(const Scope* scope)
|
|||
for (std::size_t j = 0U; j < symbolDatabase->classAndStructScopes.size(); ++j) {
|
||||
const Scope *scope2 = symbolDatabase->classAndStructScopes[j];
|
||||
if (scope2->className == structname && scope2->numConstructors == 0U) {
|
||||
for (std::list<Variable>::const_iterator it = scope2->varlist.begin(); it != scope2->varlist.end(); ++it)
|
||||
checkScopeForVariable(scope, tok, *i, NULL, NULL, it->name());
|
||||
for (std::list<Variable>::const_iterator it = scope2->varlist.begin(); it != scope2->varlist.end(); ++it) {
|
||||
const Variable &var = *it;
|
||||
if (!var.isArray())
|
||||
checkScopeForVariable(scope, tok, *i, NULL, NULL, var.name());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2708,6 +2708,14 @@ private:
|
|||
" if (foo(&s_d.type)){}\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
// address of member
|
||||
checkUninitVar2("struct AB { int a[10]; int b; };\n"
|
||||
"void f() {\n"
|
||||
" struct AB ab;\n"
|
||||
" int *p = ab.a;\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void uninitvar2_while() {
|
||||
|
|
Loading…
Reference in New Issue