Fixed #7420 ((debug) Executable scope 'foo' with unknown function.)

This commit is contained in:
Robert Reif 2016-03-22 14:10:20 +01:00 committed by Daniel Marjamäki
parent ac8341e3de
commit 47634a0ada
2 changed files with 31 additions and 0 deletions

View File

@ -1621,6 +1621,13 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
// skip variable names
first = first->next();
second = second->next();
// skip default value assignment
if (first->next()->str() == "=") {
do {
first = first->next();
} while (!Token::Match(first->next(), ",|)"));
}
}
// variable with class path

View File

@ -276,6 +276,8 @@ private:
TEST_CASE(lambda); // ticket #5867
TEST_CASE(circularDependencies); // 6298
TEST_CASE(executableScopeWithUnknownFunction);
TEST_CASE(valuetype);
}
@ -3119,6 +3121,28 @@ private:
"}");
}
void executableScopeWithUnknownFunction() {
GET_SYMBOL_DB("class Fred {\n"
" void foo(const std::string & a = "");\n"
"};\n"
"Fred::foo(const std::string & b) { }\n");
ASSERT(db && db->scopeList.size() == 3);
if (db && db->scopeList.size() == 3) {
std::list<Scope>::const_iterator scope = db->scopeList.begin();
ASSERT_EQUALS(Scope::eGlobal, scope->type);
++scope;
ASSERT_EQUALS(Scope::eClass, scope->type);
const Scope * class_scope = &*scope;
++scope;
ASSERT(class_scope->functionList.size() == 1);
if (class_scope->functionList.size() == 1) {
ASSERT(class_scope->functionList.begin()->hasBody());
ASSERT(class_scope->functionList.begin()->functionScope == &*scope);
}
}
}
std::string typeOf(const char code[], const char pattern[], const char filename[] = "test.cpp") {
Tokenizer tokenizer(&settings2, this);
std::istringstream istr(code);