Fixed ticket #572 (Tokenizer: improve detection of arrays)
http://sourceforge.net/apps/trac/cppcheck/ticket/572
This commit is contained in:
parent
5f3baba178
commit
1fd2c0ff28
|
@ -2326,12 +2326,14 @@ bool Tokenizer::simplifyVarDecl()
|
|||
}
|
||||
}
|
||||
|
||||
else if (Token::Match(tok2, "%type% %var% [ %num% ] ,"))
|
||||
else if (Token::Match(tok2, "%type% %var% [ %num% ] ,") ||
|
||||
Token::Match(tok2, "%type% %var% [ %var% ] ,"))
|
||||
{
|
||||
tok2 = tok2->tokAt(5); // The ',' token
|
||||
}
|
||||
|
||||
else if (Token::Match(tok2, "%type% * %var% [ %num% ] ,"))
|
||||
else if (Token::Match(tok2, "%type% * %var% [ %num% ] ,") ||
|
||||
Token::Match(tok2, "%type% * %var% [ %var% ] ,"))
|
||||
{
|
||||
tok2 = tok2->tokAt(6); // The ',' token
|
||||
}
|
||||
|
|
|
@ -1108,6 +1108,15 @@ private:
|
|||
"}\n";
|
||||
ASSERT_EQUALS(" void f ( ) { for ( int a , b ; a < 10 ; a = a + 1 , b = b + 1 ) { ; } }", sizeof_(code));
|
||||
}
|
||||
|
||||
{
|
||||
const char code[] = "void f()\n"
|
||||
"{\n"
|
||||
" char buf[BUFSIZ], **p;\n"
|
||||
" char *ptrs[BUFSIZ], **pp;\n"
|
||||
"}\n";
|
||||
ASSERT_EQUALS(" void f ( ) { char buf [ BUFSIZ ] ; char * * p ; char * ptrs [ BUFSIZ ] ; char * * pp ; }", sizeof_(code));
|
||||
}
|
||||
}
|
||||
|
||||
void remove_comma()
|
||||
|
|
Loading…
Reference in New Issue