Fix #1532 (hang due to commit 772aa95c8a)

http://sourceforge.net/apps/trac/cppcheck/ticket/1532
This commit is contained in:
Reijo Tomperi 2010-03-27 21:52:31 +02:00
parent a18c964efa
commit 86fabd03b3
2 changed files with 3 additions and 0 deletions

View File

@ -6672,6 +6672,8 @@ void Tokenizer::simplifyStructInit()
tok2 = tok2->tokAt(4); tok2 = tok2->tokAt(4);
else if (Token::Match(tok2, ". %type% = & %var% [,}]")) else if (Token::Match(tok2, ". %type% = & %var% [,}]"))
tok2 = tok2->tokAt(5); tok2 = tok2->tokAt(5);
else
break;
if (Token::simpleMatch(tok2, ", .")) if (Token::simpleMatch(tok2, ", ."))
tok2 = tok2->next(); tok2 = tok2->next();

View File

@ -4128,6 +4128,7 @@ private:
ASSERT_EQUALS("; struct A a ; a . buf = x ;", tok("; struct A a = { .buf = x };")); ASSERT_EQUALS("; struct A a ; a . buf = x ;", tok("; struct A a = { .buf = x };"));
ASSERT_EQUALS("; struct A a ; a . buf = & key ;", tok("; struct A a = { .buf = &key };")); ASSERT_EQUALS("; struct A a ; a . buf = & key ;", tok("; struct A a = { .buf = &key };"));
ASSERT_EQUALS("; struct ABC abc ; abc . a = 3 ; abc . b = x ; abc . c = & key ;", tok("; struct ABC abc = { .a = 3, .b = x, .c = &key };")); ASSERT_EQUALS("; struct ABC abc ; abc . a = 3 ; abc . b = x ; abc . c = & key ;", tok("; struct ABC abc = { .a = 3, .b = x, .c = &key };"));
TODO_ASSERT_EQUALS("; struct A a ; a . buf = { 0 } ;", tok("; struct A a = { .buf = {0} };"));
} }
void simplifyStructDecl() void simplifyStructDecl()