diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 987131bdf..69c1da3af 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -599,7 +599,7 @@ static void compileTerm(Token *&tok, AST_state& state) compileUnaryOp(tok, state, compileExpression); else compileBinOp(tok, state, compileExpression); - if (Token::simpleMatch(tok, "} ,")) { + if (Token::Match(tok, "} ,|:")) { tok = tok->next(); } } else if (!state.inArrayAssignment && !Token::simpleMatch(prev, "=")) { diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 8188287d1..ddb456a29 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -74,6 +74,7 @@ private: TEST_CASE(tokenize33); // #5780 Various crashes on valid template code TEST_CASE(tokenize34); // #8031 TEST_CASE(tokenize35); // #8361 + TEST_CASE(tokenize36); // #8436 TEST_CASE(validate); @@ -850,6 +851,11 @@ private: "template ::CRCWord const Compute(T const t) { return 0; }"); } + void tokenize36() { // #8436 + const char code[] = "int foo ( int i ) { return i ? * new int { 5 } : int { i ? 0 : 1 } ; }"; + ASSERT_EQUALS(code, tokenizeAndStringify(code)); + } + void validate() { // C++ code in C file ASSERT_THROW(tokenizeAndStringify(";using namespace std;",false,false,Settings::Native,"test.c"), InternalError);