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()