Skip to content

Commit 47634a0

Browse files
IOBYTEdanmar
authored andcommitted
Fixed #7420 ((debug) Executable scope 'foo' with unknown function.)
1 parent ac8341e commit 47634a0

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

lib/symboldatabase.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,6 +1621,13 @@ bool Function::argsMatch(const Scope *scope, const Token *first, const Token *se
16211621
// skip variable names
16221622
first = first->next();
16231623
second = second->next();
1624+
1625+
// skip default value assignment
1626+
if (first->next()->str() == "=") {
1627+
do {
1628+
first = first->next();
1629+
} while (!Token::Match(first->next(), ",|)"));
1630+
}
16241631
}
16251632

16261633
// variable with class path

test/testsymboldatabase.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,8 @@ class TestSymbolDatabase: public TestFixture {
276276
TEST_CASE(lambda); // ticket #5867
277277
TEST_CASE(circularDependencies); // 6298
278278

279+
TEST_CASE(executableScopeWithUnknownFunction);
280+
279281
TEST_CASE(valuetype);
280282
}
281283

@@ -3119,6 +3121,28 @@ class TestSymbolDatabase: public TestFixture {
31193121
"}");
31203122
}
31213123

3124+
void executableScopeWithUnknownFunction() {
3125+
GET_SYMBOL_DB("class Fred {\n"
3126+
" void foo(const std::string & a = "");\n"
3127+
"};\n"
3128+
"Fred::foo(const std::string & b) { }\n");
3129+
3130+
ASSERT(db && db->scopeList.size() == 3);
3131+
if (db && db->scopeList.size() == 3) {
3132+
std::list<Scope>::const_iterator scope = db->scopeList.begin();
3133+
ASSERT_EQUALS(Scope::eGlobal, scope->type);
3134+
++scope;
3135+
ASSERT_EQUALS(Scope::eClass, scope->type);
3136+
const Scope * class_scope = &*scope;
3137+
++scope;
3138+
ASSERT(class_scope->functionList.size() == 1);
3139+
if (class_scope->functionList.size() == 1) {
3140+
ASSERT(class_scope->functionList.begin()->hasBody());
3141+
ASSERT(class_scope->functionList.begin()->functionScope == &*scope);
3142+
}
3143+
}
3144+
}
3145+
31223146
std::string typeOf(const char code[], const char pattern[], const char filename[] = "test.cpp") {
31233147
Tokenizer tokenizer(&settings2, this);
31243148
std::istringstream istr(code);

0 commit comments

Comments
 (0)