tokenizer: fixed TestTokenizer::sizeof1

This commit is contained in:
Daniel Marjamäki 2009-01-28 17:38:32 +00:00
parent dd9cd9ce82
commit b7b055e885
2 changed files with 14 additions and 2 deletions

View File

@ -675,7 +675,19 @@ void Tokenizer::simplifyTokenList()
else if (Token::Match(tok, "sizeof ( * %var% )"))
{
tok->str("100");
// Some default value..
int sz = 100;
// Try to locate variable declaration..
const Token *decltok = Token::findmatch(_tokens, (std::string("%type% ") + tok->strAt(3) + " [").c_str());
if (decltok)
{
sz = SizeOfType(decltok->strAt(0));
}
std::ostringstream ostr;
ostr << sz;
tok->str(ostr.str().c_str());
for (int i = 0; i < 4; ++i)
tok->deleteNext();
}