diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 380446b32..a2f44f2ca 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -934,10 +934,15 @@ static void compileScope(Token *&tok, AST_state& state) static bool isPrefixUnary(const Token* tok, bool cpp) { if (!tok->previous() - || ((Token::Match(tok->previous(), "(|[|{|%op%|;|}|?|:|,|.|return|::") || (cpp && tok->strAt(-1) == "throw")) + || ((Token::Match(tok->previous(), "(|[|{|%op%|;|?|:|,|.|return|::") || (cpp && tok->strAt(-1) == "throw")) && (tok->previous()->tokType() != Token::eIncDecOp || tok->tokType() == Token::eIncDecOp))) return true; + if (tok->previous()->str() == "}") { + const Token* parent = tok->linkAt(-1)->tokAt(-1); + return !Token::Match(parent, "%type%") || parent->isKeyword(); + } + if (tok->str() == "*" && tok->previous()->tokType() == Token::eIncDecOp && isPrefixUnary(tok->previous(), cpp)) return true; diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index c7ba4c68f..dfa0f57e8 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -6428,6 +6428,9 @@ private: ASSERT_EQUALS("ab4<