add support for anonymous struct to symbol database

This commit is contained in:
Robert Reif 2011-03-29 07:08:59 -04:00
parent e9a23d9cb5
commit 678486f0db
1 changed files with 5 additions and 3 deletions

View File

@ -110,8 +110,8 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
tok = tok->tokAt(3); tok = tok->tokAt(3);
} }
// anonymous union // anonymous struct and union
else if (Token::Match(tok, "union {") && else if (Token::Match(tok, "struct|union {") &&
Token::Match(tok->next()->link(), "} %var% ;")) Token::Match(tok->next()->link(), "} %var% ;"))
{ {
scopeList.push_back(Scope(this, tok, scope)); scopeList.push_back(Scope(this, tok, scope));
@ -1338,6 +1338,8 @@ Scope::Scope(SymbolDatabase *check_, const Token *classDef_, Scope *nestedIn_) :
else if (classDef->str() == "struct") else if (classDef->str() == "struct")
{ {
type = Scope::eStruct; type = Scope::eStruct;
// anonymous structs don't have a name
if (classDef->next()->str() != "{")
className = classDef->next()->str(); className = classDef->next()->str();
access = Public; access = Public;
} }