diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 6e3836d40..6df2070d5 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -911,7 +911,7 @@ static Token * createAstAtToken(Token *tok, bool cpp) if (Token::Match(tok, "%type% <") && Token::Match(tok->linkAt(1), "> !!(")) return tok->linkAt(1); - if (tok->str() == "return" || !tok->previous() || Token::Match(tok, "%var% %op%|(|[|.|::") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{")) { + if (tok->str() == "return" || !tok->previous() || Token::Match(tok, "%var% %op%|(|[|.|::|<") || Token::Match(tok->previous(), "[;{}] %cop%|++|--|( !!{")) { Token * const tok1 = tok; AST_state state(cpp); compileExpression(tok, state); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index b09e4277e..a7caa72a7 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8486,6 +8486,7 @@ private: void asttemplate() const { // uninstantiated templates will have <,>,etc.. ASSERT_EQUALS("a(3==", testAst("a()==3")); ASSERT_EQUALS("ab(== f(", testAst("a == b(); f();")); + ASSERT_EQUALS("static_casta(i[", testAst("; static_cast(a)[i];")); // #6203 // This two unit tests were added to avoid a crash. The actual correct AST result for non-executable code has not been determined so far. ASSERT_EQUALS("Cpublica::b:::", testAst("class C : public ::a::b { };"));