Fixed #732 (Tokenizer: Incorrect simplification)

Regression since 58a9e05697 commit.

http://sourceforge.net/apps/trac/cppcheck/ticket/732
This commit is contained in:
Slava Semushin 2009-09-26 17:02:13 +07:00
parent 0b3a139b3b
commit a919f4541a
2 changed files with 13 additions and 0 deletions

View File

@ -2570,7 +2570,11 @@ void Tokenizer::simplifyVarDecl()
{
if (tok2->str() == "{")
tok2 = tok2->link();
tok2 = tok2->next();
if (tok2->str() == ";")
tok2 = NULL;
}
}
}

View File

@ -142,6 +142,7 @@ private:
TEST_CASE(vardecl7);
TEST_CASE(vardecl8);
TEST_CASE(vardecl9);
TEST_CASE(vardecl10);
TEST_CASE(vardecl_stl);
TEST_CASE(volatile_variables);
TEST_CASE(syntax_error);
@ -2289,6 +2290,14 @@ private:
ASSERT_EQUALS(res, tokenizeAndStringify(code));
}
void vardecl10()
{
// ticket #732
const char code[] = "char a [ 2 ] = { '-' } ; memset ( a , '-' , sizeof ( a ) ) ;";
ASSERT_EQUALS(code, tokenizeAndStringify(code));
}
void volatile_variables()
{
const char code[] = "volatile int a=0;\n"