Tokenizer::setVarId: Proper handling of 'void f(struct foobar). Ticket: #4444'

This commit is contained in:
Daniel Marjamäki 2012-12-29 08:54:39 +01:00
parent 38d1b064e8
commit 9af51a75e6
2 changed files with 7 additions and 1 deletions

View File

@ -2754,7 +2754,7 @@ void Tokenizer::setVarId()
continue; continue;
const Token *tok3 = tok2->next(); const Token *tok3 = tok2->next();
if (!tok3->isStandardType() && !setVarIdParseDeclaration(&tok3,variableId,executableScope.top())) { if (!tok3->isStandardType() && !Token::Match(tok3,"struct|union|class %type%") && !setVarIdParseDeclaration(&tok3,variableId,executableScope.top())) {
variableId[tok2->previous()->str()] = ++_varId; variableId[tok2->previous()->str()] = ++_varId;
tok = tok2->previous(); tok = tok2->previous();
} }

View File

@ -3749,6 +3749,12 @@ private:
ASSERT_EQUALS(expected, actual); ASSERT_EQUALS(expected, actual);
} }
{
const std::string actual = tokenizeDebugListing("void f(struct foobar);", false, "test.c");
const std::string expected("\n\n##file 0\n"
"1: void f ( struct foobar ) ;\n");
ASSERT_EQUALS(expected, actual);
}
} }
void varid_sizeof() { void varid_sizeof() {