From 86fabd03b3ba5f151b23e77a877d196120fca48f Mon Sep 17 00:00:00 2001 From: Reijo Tomperi Date: Sat, 27 Mar 2010 21:52:31 +0200 Subject: [PATCH] Fix #1532 (hang due to commit 772aa95c8a) http://sourceforge.net/apps/trac/cppcheck/ticket/1532 --- lib/tokenize.cpp | 2 ++ test/testsimplifytokens.cpp | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 989335023..11f84643b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -6672,6 +6672,8 @@ void Tokenizer::simplifyStructInit() tok2 = tok2->tokAt(4); else if (Token::Match(tok2, ". %type% = & %var% [,}]")) tok2 = tok2->tokAt(5); + else + break; if (Token::simpleMatch(tok2, ", .")) tok2 = tok2->next(); diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 667f0dbae..c863f640d 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -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 = & 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 };")); + TODO_ASSERT_EQUALS("; struct A a ; a . buf = { 0 } ;", tok("; struct A a = { .buf = {0} };")); } void simplifyStructDecl()