Skip code in brackets in default argument declaration (fixes #4057)

This commit is contained in:
PKEuS 2012-09-06 20:02:53 +02:00
parent 31e7e41098
commit 20f989b6c4
2 changed files with 10 additions and 1 deletions

View File

@ -1621,8 +1621,11 @@ void Function::addArguments(const SymbolDatabase *symbolDatabase, const Scope *s
// skip default values
if (tok->str() == "=") {
while (tok->str() != "," && tok->str() != ")")
while (tok->str() != "," && tok->str() != ")") {
if (tok->link())
tok = tok->link();
tok = tok->next();
}
}
argumentList.push_back(Variable(nameTok, startTok, endTok, count++, Argument, argType, functionScope));

View File

@ -852,6 +852,12 @@ private:
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().index() == 0);
ASSERT_EQUALS("", errout.str());
}
{
GET_SYMBOL_DB("void g(std::map<int, int> m = std::map<int, int>()) { }");
const Scope* g = db->findScopeByName("g");
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().index() == 0 && g->function->initializedArgCount() == 1);
ASSERT_EQUALS("", errout.str());
}
}
void functionArgs2() {