diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 46de19d75..914189fcb 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -2046,7 +2046,10 @@ Function* SymbolDatabase::addGlobalFunction(Scope*& scope, const Token*& tok, co { Function* function = nullptr; for (std::multimap::iterator i = scope->functionMap.find(tok->str()); i != scope->functionMap.end() && i->first == tok->str(); ++i) { - if (Function::argsMatch(scope, i->second->argDef->next(), argStart->next(), emptyString, 0)) { + const Function *f = i->second; + if (f->hasBody()) + continue; + if (Function::argsMatch(scope, f->argDef->next(), argStart->next(), emptyString, 0)) { function = const_cast(i->second); break; } diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 2b4b52bf5..384e64fa1 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -290,6 +290,7 @@ private: TEST_CASE(symboldatabase70); TEST_CASE(symboldatabase71); TEST_CASE(symboldatabase72); // #8600 + TEST_CASE(symboldatabase73); // #8603 TEST_CASE(enum1); TEST_CASE(enum2); @@ -3941,6 +3942,26 @@ private: ASSERT(f && f->function() && f->function()->type == Function::eCopyConstructor); } + void symboldatabase73() { // #8603 + GET_SYMBOL_DB("namespace swizzle {\n" + " template void swizzle(tvec2) {}\n" + " template void swizzle(tvec2 v) {}\n" + "}"); + + ASSERT_EQUALS(4, db->scopeList.size()); + ASSERT_EQUALS(2, db->functionScopes.size()); + + const Scope *f1 = db->functionScopes[0]; + ASSERT_EQUALS(2, f1->bodyStart->linenr()); + ASSERT_EQUALS(2, f1->bodyEnd->linenr()); + ASSERT_EQUALS(2, f1->function->token->linenr()); + + const Scope *f2 = db->functionScopes[1]; + ASSERT_EQUALS(3, f2->bodyStart->linenr()); + ASSERT_EQUALS(3, f2->bodyEnd->linenr()); + ASSERT_EQUALS(3, f2->function->token->linenr()); + } + void enum1() { GET_SYMBOL_DB("enum BOOL { FALSE, TRUE }; enum BOOL b;");