Additional fix for better simplifying array declaration.

Pointed out by hyd_danmar@ in IRC.

Addressed to #696
This commit is contained in:
Slava Semushin 2009-09-20 18:28:56 +07:00
parent 5dee65048f
commit 7236230228
2 changed files with 11 additions and 0 deletions

View File

@ -2511,6 +2511,8 @@ void Tokenizer::simplifyVarDecl()
{ {
while (tok2 && tok2->str() != ",") while (tok2 && tok2->str() != ",")
{ {
if (tok2->str() == "{")
tok2 = tok2->link();
tok2 = tok2->next(); tok2 = tok2->next();
} }
} }

View File

@ -140,6 +140,7 @@ private:
TEST_CASE(vardecl6); TEST_CASE(vardecl6);
TEST_CASE(vardecl7); TEST_CASE(vardecl7);
TEST_CASE(vardecl8); TEST_CASE(vardecl8);
TEST_CASE(vardecl9);
TEST_CASE(vardecl_stl); TEST_CASE(vardecl_stl);
TEST_CASE(volatile_variables); TEST_CASE(volatile_variables);
TEST_CASE(syntax_error); TEST_CASE(syntax_error);
@ -2246,6 +2247,14 @@ private:
ASSERT_EQUALS(res, tokenizeAndStringify(code)); ASSERT_EQUALS(res, tokenizeAndStringify(code));
} }
void vardecl9()
{
const char code[] = "char a[2] = {'A', '\\0'}, b[2] = {'B', '\\0'};";
const char res[] = "char a [ 2 ] = { 'A' , '\\0' } ; char b [ 2 ] = { 'B' , '\\0' } ;";
ASSERT_EQUALS(res, tokenizeAndStringify(code));
}
void volatile_variables() void volatile_variables()
{ {
const char code[] = "volatile int a=0;\n" const char code[] = "volatile int a=0;\n"