Fixed #7420 ((debug) Executable scope 'foo' with unknown function.)
This commit is contained in:
parent
ac8341e3de
commit
47634a0ada
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue