diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index df754288c..dee16d2bc 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -558,7 +558,7 @@ static bool iscast(const Token *tok, bool cpp) static Token* findTypeEnd(Token* tok) { - while (Token::Match(tok, "%name%|.|::|*|&|<|(|template|decltype|sizeof")) { + while (Token::Match(tok, "%name%|.|::|*|&|&&|<|(|template|decltype|sizeof")) { if (Token::Match(tok, "(|<")) tok = tok->link(); if (!tok) @@ -949,9 +949,8 @@ static void compilePrecedence2(Token *&tok, AST_state& state) Token* curlyBracket = roundBracket->link()->next(); if (Token::Match(curlyBracket, "mutable|const|noexcept")) curlyBracket = curlyBracket->next(); - if (curlyBracket && curlyBracket->originalName() == "->") { + if (curlyBracket && curlyBracket->originalName() == "->") curlyBracket = findTypeEnd(curlyBracket->next()); - } if (curlyBracket && curlyBracket->str() == "{") { squareBracket->astOperand1(roundBracket); roundBracket->astOperand1(curlyBracket); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 36943ddc9..f0b24aaba 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -8023,6 +8023,7 @@ private: ASSERT_EQUALS("{([return", testAst("return []() -> decltype(0) {};")); ASSERT_EQUALS("x{(&[=", testAst("x = [&]()->std::string const & {};")); ASSERT_EQUALS("f{([=", testAst("f = []() -> foo* {};")); + ASSERT_EQUALS("f{([=", testAst("f = []() -> foo&& {};")); ASSERT_EQUALS("f{([=", testAst("f = [](void) mutable -> foo* {};")); ASSERT_EQUALS("f{([=", testAst("f = []() mutable {};"));