diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 20048e5a4..dc2165347 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -803,7 +803,14 @@ static void compileTerm(Token *&tok, AST_state& state) if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% (")) { if (Token::Match(tok, "{ !!}")) { Token *const end = tok->link(); - compileUnaryOp(tok, state, compileExpression); + if (Token::Match(tok, "{ . %name% =|{")) { + const int inArrayAssignment = state.inArrayAssignment; + state.inArrayAssignment = 1; + compileBinOp(tok, state, compileExpression); + state.inArrayAssignment = inArrayAssignment; + } else { + compileUnaryOp(tok, state, compileExpression); + } if (precedes(tok,end)) tok = end; } else { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 2b1412a99..102dab9c5 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6107,6 +6107,7 @@ private: ASSERT_EQUALS("a0{,( \"\"abc12:?,", testAst("a(0, {{\"\", (abc) ? 1 : 2}});")); ASSERT_EQUALS("a0{,( \'\'abc12:?,", testAst("a(0, {{\'\', (abc) ? 1 : 2}});")); ASSERT_EQUALS("x12,{34,{,{56,{78,{,{,{=", testAst("x = { { {1,2}, {3,4} }, { {5,6}, {7,8} } };")); + ASSERT_EQUALS("Sa.stdmove::s(=b.1=,{(", testAst("S({.a = std::move(s), .b = 1})")); // struct initialization hang ASSERT_EQUALS("sbar.1{,{(={= forfieldfield++;;(",