From 8a72bb8aa8d9b3be4c167d9b604500751c6cb958 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 21 Jul 2015 11:40:42 +0200 Subject: [PATCH] AST: Fixed AST for struct initialisation --- lib/tokenlist.cpp | 5 ++++- test/testtokenize.cpp | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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