diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 7a9da6361..e2b7c89f3 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -868,8 +868,13 @@ void Variable::evaluate() setFlag(fIsArray, arrayDimensions(_dimensions, _name->next())); if (_start) setFlag(fIsClass, !_start->isStandardType() && !isPointer() && !isReference()); - if (_access == Argument && _name) { - tok = _name->next(); + if (_access == Argument) { + tok = _name; + if (!tok) + tok = _end; // Argument without name + if (!tok) + return; + tok = tok->next(); while (tok->str() == "[") tok = tok->link(); setFlag(fHasDefault, tok->str() == "="); diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 60aac8951..cf185a053 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -858,6 +858,12 @@ private: 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()); } + { + GET_SYMBOL_DB("void g(int = 0) { }"); + const Scope* g = db->findScopeByName("g"); + ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().hasDefault()); + ASSERT_EQUALS("", errout.str()); + } } void functionArgs2() {