diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 2f51bfef8d2..26a9580cc9d 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -831,7 +831,7 @@ static void compileTerm(Token *&tok, AST_state& state) } else if ((state.cpp && iscpp11init(tok)) || Token::simpleMatch(tok->previous(), "] {")) { Token *const end = tok->link(); if (state.op.empty() || Token::Match(tok->previous(), "[{,]") || Token::Match(tok->tokAt(-2), "%name% (")) { - if (Token::Match(tok->tokAt(-1), "!!, { . %name% =|{")) { + if (Token::Match(tok->tokAt(-1), "!!, { . %name% =|{") && !Token::simpleMatch(tok->tokAt(-1), "(")) { const int inArrayAssignment = state.inArrayAssignment; state.inArrayAssignment = 1; compileBinOp(tok, state, compileExpression); diff --git a/test/testother.cpp b/test/testother.cpp index 8c037fe5288..834b10ce0b4 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3902,6 +3902,9 @@ class TestOther : public TestFixture { "[test.cpp:7:10]: (style) Parameter 't' can be declared as reference to const [constParameterReference]\n" "[test.cpp:10:25]: (style) Parameter 'v' can be declared as reference to const [constParameterReference]\n", errout_str()); + + check("void push(V& v) { v.push_back({ .x = 1 }); }"); // #14010 + ASSERT_EQUALS("", errout_str()); } void constParameterCallback() { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 7107eb091d0..2fbef515a62 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -403,6 +403,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astvardecl); TEST_CASE(astnewscoped); TEST_CASE(astdecltypescope); + TEST_CASE(astdesignatedinit); TEST_CASE(startOfExecutableScope); @@ -7176,6 +7177,10 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("sizedecltypethism_P.(XSize::::{", testAst("size { decltype(this->m_P)::X::Size };")); } + void astdesignatedinit() { + ASSERT_EQUALS("(( f ({ (= (. x) 1)))", testAst("f({ .x = 1 });", AstStyle::Z3)); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) {