diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 1138b410ddd..03095a40992 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -873,7 +873,7 @@ static void compileTerm(Token *&tok, AST_state& state) state.inArrayAssignment--; tok = tok1->link()->next(); } - } else if (!state.inArrayAssignment && !Token::simpleMatch(prev, "=")) { + } else if ((!state.inArrayAssignment && !Token::simpleMatch(prev, "=")) || Token::simpleMatch(prev, "?")) { state.op.push(tok); tok = tok->link()->next(); } else { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index ee38b2a1dce..7aca456a445 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -426,6 +426,7 @@ class TestTokenizer : public TestFixture { TEST_CASE(astrvaluedecl); TEST_CASE(astorkeyword); TEST_CASE(astenumdecl); + TEST_CASE(astcompound); TEST_CASE(startOfExecutableScope); @@ -7422,6 +7423,11 @@ class TestTokenizer : public TestFixture { ASSERT_EQUALS("A0U=", testAst("enum myclass : unsigned char { A = 0U, };")); } + void astcompound() { + ASSERT_EQUALS("sn0=={(tmp:?=", testAst("Str s = n == 0 ? (Str) { 0 } : tmp;")); // #14548 + ASSERT_EQUALS("s(sstrlens(0:?,{(return", testAst("return (struct Str) { (unsigned char*)s, s ? strlen(s) : 0 };")); + } + #define isStartOfExecutableScope(offset, code) isStartOfExecutableScope_(offset, code, __FILE__, __LINE__) template bool isStartOfExecutableScope_(int offset, const char (&code)[size], const char* file, int line) {