Fixed #1682 (Internal error)

This commit is contained in:
Daniel Marjamki 2010-05-14 18:40:15 +02:00
parent c39f80d361
commit 8b1ffefd74
2 changed files with 15 additions and 0 deletions

View File

@ -2900,6 +2900,9 @@ void Tokenizer::simplifySizeof()
if (tok->str() != "sizeof")
continue;
if (Token::simpleMatch(tok->next(), "sizeof"))
continue;
// sizeof "text"
if (Token::Match(tok->next(), "%str%"))
{

View File

@ -73,6 +73,7 @@ private:
TEST_CASE(sizeof16);
TEST_CASE(sizeof17);
TEST_CASE(sizeof18);
TEST_CASE(sizeofsizeof);
TEST_CASE(casting);
TEST_CASE(strlen1);
@ -1251,6 +1252,17 @@ private:
}
}
void sizeofsizeof()
{
// ticket #1682
const char code[] = "void f()\n"
"{\n"
" sizeof sizeof 1;\n"
"}\n";
ASSERT_EQUALS("void f ( ) { sizeof sizeof ( 1 ) ; }", tok(code));
ASSERT_EQUALS("", errout.str());
}
void casting()
{
{