SymbolDatabase: Fixed parsing of unnamed arguments, properly detect pointers (#8052)

This commit is contained in:
PKEuS 2017-05-07 09:03:30 +02:00
parent 28b8bc57a8
commit 68d77b73da
2 changed files with 10 additions and 1 deletions

View File

@ -1725,7 +1725,10 @@ void Variable::evaluate(const Library* lib)
const Token* tok = _start;
while (tok && tok->previous() && tok->previous()->isName())
tok = tok->previous();
for (const Token* const end = _name?_name:_end; tok != end;) {
const Token* end = _end;
if (end)
end = end->next();
while (tok != end) {
if (tok->str() == "static")
setFlag(fIsStatic, true);
else if (tok->str() == "extern")

View File

@ -1615,6 +1615,12 @@ private:
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().hasDefault());
ASSERT_EQUALS("", errout.str());
}
{
GET_SYMBOL_DB("void g(int*) { }"); // unnamed pointer argument (#8052)
const Scope* g = db->findScopeByName("g");
ASSERT(g && g->type == Scope::eFunction && g->function && g->function->argumentList.size() == 1 && g->function->argumentList.front().nameToken() == nullptr && g->function->argumentList.front().isPointer());
ASSERT_EQUALS("", errout.str());
}
{
GET_SYMBOL_DB("void g(int* const) { }"); // 'const' is not the name of the variable - #5882
const Scope* g = db->findScopeByName("g");