From 20f989b6c402d1f6fadfec047f6b03a011294be7 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Thu, 6 Sep 2012 20:02:53 +0200 Subject: [PATCH] Skip code in brackets in default argument declaration (fixes #4057) --- lib/symboldatabase.cpp | 5 ++++- test/testsymboldatabase.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index eafc2800e..7a9da6361 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -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)); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 98c0701f9..60aac8951 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -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 m = std::map()) { }"); + 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() {