diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index c30f9db3d..acc7f93bc 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -540,7 +540,10 @@ static void compileTerm(Token *&tok, AST_state& state) if (tok->link() != tok->next()) { state.inArrayAssignment++; compileUnaryOp(tok, state, compileExpression); - state.inArrayAssignment--; + while (Token::Match(tok, "} [,}]") && state.inArrayAssignment > 0U) { + tok = tok->next(); + state.inArrayAssignment--; + } } else { state.op.push(tok); } diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ffbadc4d0..9d727b261 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8598,6 +8598,7 @@ private: ASSERT_EQUALS("name_bytes[bits~unusedBits>>unusedBits<<{=", testAst("const uint8_t name_bytes[] = { (~bits >> unusedBits) << unusedBits };")); ASSERT_EQUALS("abuf0{={=", testAst("a = { .buf = { 0 } };")); ASSERT_EQUALS("tset{=", testAst("struct cgroup_taskset tset = {};")); + ASSERT_EQUALS("s1a&,{2b&,{,{=", testAst("s = { {1, &a}, {2, &b} };")); // template paratheses: <> ASSERT_EQUALS("stdfabs::m_similarity(numeric_limitsepsilon::(<=return", testAst("return std::fabs(m_similarity) <= numeric_limits::epsilon();")); // #6195