Fixed #1050 (Internal error: In tokenizer for: 'do { sizeof 1; } while (0);')
This commit is contained in:
parent
e66156ab5c
commit
75f6e20e61
|
@ -1745,8 +1745,17 @@ void Tokenizer::simplifySizeof()
|
|||
Token::createMutualLinks(tok->next(), tok->tokAt(4));
|
||||
}
|
||||
|
||||
// sizeof 1 => sizeof ( 1 )
|
||||
if (tok->next()->isNumber())
|
||||
{
|
||||
Token *tok2 = tok->next();
|
||||
tok->insertToken("(");
|
||||
tok2->insertToken(")");
|
||||
Token::createMutualLinks(tok->next(), tok2->next());
|
||||
}
|
||||
|
||||
// sizeof int -> sizeof( int )
|
||||
if (tok->next()->str() != "(")
|
||||
else if (tok->next()->str() != "(")
|
||||
{
|
||||
// Add parenthesis around the sizeof
|
||||
for (Token *tempToken = tok->next(); tempToken; tempToken = tempToken->next())
|
||||
|
|
|
@ -72,6 +72,7 @@ private:
|
|||
TEST_CASE(sizeof14);
|
||||
TEST_CASE(sizeof15);
|
||||
TEST_CASE(sizeof16);
|
||||
TEST_CASE(sizeof17);
|
||||
TEST_CASE(casting);
|
||||
|
||||
TEST_CASE(strlen1);
|
||||
|
@ -938,6 +939,18 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void sizeof17()
|
||||
{
|
||||
// ticket #1050
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" sizeof 1;\n"
|
||||
" while (0);\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS("void f ( ) { sizeof ( 1 ) ; while ( false ) { ; } }", tok(code));
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void casting()
|
||||
{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue