Support default arguments in symboldatabase for arguments without name (#4055)

This commit is contained in:
PKEuS 2012-09-06 20:50:46 +02:00
parent 6023ae423c
commit c2d4afc525
2 changed files with 13 additions and 2 deletions

View File

@ -868,8 +868,13 @@ void Variable::evaluate()
setFlag(fIsArray, arrayDimensions(_dimensions, _name->next())); setFlag(fIsArray, arrayDimensions(_dimensions, _name->next()));
if (_start) if (_start)
setFlag(fIsClass, !_start->isStandardType() && !isPointer() && !isReference()); setFlag(fIsClass, !_start->isStandardType() && !isPointer() && !isReference());
if (_access == Argument && _name) { if (_access == Argument) {
tok = _name->next(); tok = _name;
if (!tok)
tok = _end; // Argument without name
if (!tok)
return;
tok = tok->next();
while (tok->str() == "[") while (tok->str() == "[")
tok = tok->link(); tok = tok->link();
setFlag(fHasDefault, tok->str() == "="); setFlag(fHasDefault, tok->str() == "=");

View File

@ -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(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()); 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() { void functionArgs2() {