Fixed #4261 (CheckOther::checkComparisonOfFuncReturningBool using wrong function scope test)
This commit is contained in:
parent
74d735247f
commit
8ccbde117a
|
@ -2227,9 +2227,9 @@ void CheckOther::checkComparisonOfFuncReturningBool()
|
|||
|
||||
const SymbolDatabase * const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
if (!scope->isExecutable())
|
||||
continue;
|
||||
size_t functions = symbolDatabase->functionScopeList.size();
|
||||
for (size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopeList[i];
|
||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||
if (tok->type() != Token::eComparisonOp || tok->str() == "==" || tok->str() == "!=")
|
||||
continue;
|
||||
|
@ -2307,9 +2307,9 @@ void CheckOther::checkComparisonOfBoolWithBool()
|
|||
|
||||
const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase();
|
||||
|
||||
for (std::list<Scope>::const_iterator scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) {
|
||||
if (!scope->isExecutable())
|
||||
continue;
|
||||
size_t functions = symbolDatabase->functionScopeList.size();
|
||||
for (size_t i = 0; i < functions; ++i) {
|
||||
const Scope * scope = symbolDatabase->functionScopeList[i];
|
||||
for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) {
|
||||
if (tok->type() != Token::eComparisonOp || tok->str() == "==" || tok->str() == "!=")
|
||||
continue;
|
||||
|
|
|
@ -623,6 +623,12 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
|
|||
}
|
||||
}
|
||||
|
||||
// fill in function list
|
||||
for (it = scopeList.begin(); it != scopeList.end(); ++it) {
|
||||
if (it->type == Scope::eFunction)
|
||||
functionScopeList.push_back(&*it);
|
||||
}
|
||||
|
||||
// determine if user defined type needs initialization
|
||||
unsigned int unknowns = 0; // stop checking when there are no unknowns
|
||||
unsigned int retry = 0; // bail if we don't resolve all the variable types for some reason
|
||||
|
|
|
@ -560,6 +560,9 @@ public:
|
|||
/** @brief Information about all namespaces/classes/structrues */
|
||||
std::list<Scope> scopeList;
|
||||
|
||||
/** @brief Fast access to function scopes */
|
||||
std::vector<Scope *> functionScopeList;
|
||||
|
||||
/**
|
||||
* @brief find a variable type if it's a user defined type
|
||||
* @param start scope to start looking in
|
||||
|
|
Loading…
Reference in New Issue