Fixed ticket #565 (Tokenizer: simplify variable declaraion like 'int z = x >> 16')
http://sourceforge.net/apps/trac/cppcheck/ticket/565
This commit is contained in:
parent
e93179dd9a
commit
50f7fa5828
|
@ -2415,12 +2415,12 @@ bool Tokenizer::simplifyVarDecl()
|
|||
int parlevel = 0;
|
||||
while (tok2)
|
||||
{
|
||||
if (strchr("{(<", tok2->str()[0]))
|
||||
if (Token::Match(tok2, "[{(<]"))
|
||||
{
|
||||
++parlevel;
|
||||
}
|
||||
|
||||
else if (strchr("})>", tok2->str()[0]))
|
||||
else if (Token::Match(tok2, "[})>]"))
|
||||
{
|
||||
if (parlevel <= 0)
|
||||
break;
|
||||
|
|
|
@ -132,6 +132,7 @@ private:
|
|||
TEST_CASE(vardecl3);
|
||||
TEST_CASE(vardecl4);
|
||||
TEST_CASE(vardecl5);
|
||||
TEST_CASE(vardecl6);
|
||||
TEST_CASE(vardecl_stl);
|
||||
TEST_CASE(volatile_variables);
|
||||
TEST_CASE(syntax_error);
|
||||
|
@ -2240,6 +2241,15 @@ private:
|
|||
ASSERT_EQUALS(code, tokenizeAndStringify(code));
|
||||
}
|
||||
|
||||
void vardecl6()
|
||||
{
|
||||
// ticket #565
|
||||
|
||||
const char code1[] = "int z = x >> 16;";
|
||||
const char res1[] = "int z ; z = x >> 16 ;";
|
||||
ASSERT_EQUALS(res1, tokenizeAndStringify(code1));
|
||||
}
|
||||
|
||||
void volatile_variables()
|
||||
{
|
||||
const char code[] = "volatile int a=0;\n"
|
||||
|
|
Loading…
Reference in New Issue