tokenizer: don't replace sizeof when size can't be determined (#233)
This commit is contained in:
parent
bd66f12e60
commit
e45bb20f92
|
@ -1010,6 +1010,8 @@ void Tokenizer::simplifyTokenList()
|
|||
}
|
||||
}
|
||||
|
||||
if (sz > 0)
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
ostr << sz;
|
||||
tok->str(ostr.str().c_str());
|
||||
|
@ -1018,6 +1020,7 @@ void Tokenizer::simplifyTokenList()
|
|||
tok->deleteNext();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Replace 'sizeof(var)'
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
TEST_CASE(sizeof4);
|
||||
TEST_CASE(sizeof5);
|
||||
TEST_CASE(sizeof6);
|
||||
TEST_CASE(sizeof7);
|
||||
TEST_CASE(casting);
|
||||
|
||||
TEST_CASE(template1);
|
||||
|
@ -448,6 +449,13 @@ private:
|
|||
ASSERT_EQUALS(expected.str(), sizeof_(code));
|
||||
}
|
||||
|
||||
void sizeof7()
|
||||
{
|
||||
const char code[] = ";INT32 i[10];\n"
|
||||
"sizeof(i[0]);\n";
|
||||
ASSERT_EQUALS(" ; INT32 i [ 10 ] ; sizeof ( i [ 0 ] ) ;", sizeof_(code));
|
||||
}
|
||||
|
||||
void casting()
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
|
|
Loading…
Reference in New Issue