Fixed #603 (Tokenizer: Incorrect simplification of < >)

http://sourceforge.net/apps/trac/cppcheck/ticket/603
This commit is contained in:
Slava Semushin 2009-08-23 13:26:16 +07:00
parent e6120a5725
commit 8cafaf2960
2 changed files with 19 additions and 0 deletions

View File

@ -2447,6 +2447,10 @@ bool Tokenizer::simplifyVarDecl()
break;
}
}
else if (tok3->str() == ";")
{
break;
}
}
if (Token::Match(tok2, ":: %type%"))

View File

@ -138,6 +138,7 @@ private:
TEST_CASE(vardecl4);
TEST_CASE(vardecl5);
TEST_CASE(vardecl6);
TEST_CASE(vardecl7);
TEST_CASE(vardecl_stl);
TEST_CASE(volatile_variables);
TEST_CASE(syntax_error);
@ -2337,6 +2338,20 @@ private:
ASSERT_EQUALS(res1, tokenizeAndStringify(code1));
}
void vardecl7()
{
// ticket #603
const char code[] = "for (int c = 0; c < 0; ++c) {}\n"
"int t;\n"
"D(3 > t, \"T\");";
const char res[] = "for ( int c = 0 ; c < 0 ; ++ c ) { }\n"
"int t ;\n"
"D ( 3 > t , \"T\" ) ;";
ASSERT_EQUALS(res, tokenizeAndStringify(code));
}
void volatile_variables()
{
const char code[] = "volatile int a=0;\n"