Fixed #8001 (AST: Wrong AST for lambda function with 'std::string const&' result type)

This commit is contained in:
Daniel Marjamäki 2017-04-18 21:21:30 +02:00
parent 82a68858ef
commit 7a26e046a8
2 changed files with 2 additions and 1 deletions

View File

@ -697,7 +697,7 @@ static void compilePrecedence2(Token *&tok, AST_state& state)
if (Token::simpleMatch(squareBracket->link(), "] (")) {
Token* const roundBracket = squareBracket->link()->next();
Token* curlyBracket = roundBracket->link()->next();
while (Token::Match(curlyBracket, "%name%|.|::"))
while (Token::Match(curlyBracket, "%name%|.|::|&"))
curlyBracket = curlyBracket->next();
if (curlyBracket && curlyBracket->str() == "{") {
squareBracket->astOperand1(roundBracket);

View File

@ -8178,6 +8178,7 @@ private:
ASSERT_EQUALS("{([(return 0return", testAst("return []() -> int { return 0; }();"));
ASSERT_EQUALS("{([(return 0return", testAst("return [something]() -> int { return 0; }();"));
ASSERT_EQUALS("{([cd,(return 0return", testAst("return [](int a, int b) -> int { return 0; }(c, d);"));
TODO_ASSERT_EQUALS("x{([=", "stdconst::x{([=&", testAst("x = [&]()->std::string const & { 1; }"));
ASSERT_EQUALS("x{([= 0return", testAst("x = [](){return 0; };"));