diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 636215114..eda959f27 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -5251,7 +5251,7 @@ void Tokenizer::createLinks2() } else if (token->str() == "<" && ((token->previous() && (token->previous()->isTemplate() || (token->previous()->isName() && !token->previous()->varId()) || - token->strAt(-1) == "]")) || + (token->strAt(-1) == "]" && !Token::Match(token->linkAt(-1)->previous(), "%name%|)")))) || Token::Match(token->next(), ">|>>"))) { type.push(token); if (token->previous()->str() == "template") diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 2d00e507f..b9f66926c 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -5955,6 +5955,7 @@ private: ASSERT_EQUALS("x00throw:?return", testAst("return x ? 0 : throw 0;")); // #9768 ASSERT_EQUALS("val0<1throwval:?return", testAst("return val < 0 ? throw 1 : val;")); // #8526 ASSERT_EQUALS("ix0<00throw:?=", testAst("int i = x < 0 ? 0 : throw 0;")); + ASSERT_EQUALS("pa[pb[<1-pa[pb[>:?return", testAst("return p[a] < p[b] ? -1 : p[a] > p[b];")); ASSERT_EQUALS("a\"\"=", testAst("a=\"\"")); ASSERT_EQUALS("a\'\'=", testAst("a=\'\'"));