Fixed #3428 (false negative: array bounds errors not found when duplicate class names present)

This commit is contained in:
Daniel Marjamäki 2011-12-18 16:35:51 +01:00
parent 2bb5de4c89
commit 1ba1be4b8d
1 changed files with 7 additions and 12 deletions

View File

@ -1405,18 +1405,6 @@ void CheckBufferOverrun::checkStructVariable()
if (!scope->isClassOrStruct())
continue;
// are there duplicate names for classes/structs?
bool duplicateNames = false;
for (std::list<Scope>::const_iterator scope2 = symbolDatabase->scopeList.begin(); scope2 != symbolDatabase->scopeList.end(); ++scope2) {
if (scope2 != scope && scope2->isClassOrStruct() && scope2->className == scope->className) {
duplicateNames = true;
break;
}
}
// TODO: handle duplicate names better (TestBufferOverrun::array_index_41)
if (duplicateNames)
continue;
// check all variables to see if they are arrays
std::list<Variable>::const_iterator var;
for (var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
@ -1433,6 +1421,13 @@ void CheckBufferOverrun::checkStructVariable()
if (func_scope->type != Scope::eFunction)
continue;
// If struct is declared in a function then check
// if scope_func matches
if (scope->nestedIn->type == Scope::eFunction &&
scope->nestedIn != &*func_scope) {
continue;
}
// check for member variables
if (func_scope->functionOf == &*scope) {
// only check non-empty function