From 7a26e046a860b912d72c5274c85061d5c4550737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Tue, 18 Apr 2017 21:21:30 +0200 Subject: [PATCH] Fixed #8001 (AST: Wrong AST for lambda function with 'std::string const&' result type) --- lib/tokenlist.cpp | 2 +- test/testtokenize.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tokenlist.cpp b/lib/tokenlist.cpp index 2c5fce4a3..dcbe69299 100644 --- a/lib/tokenlist.cpp +++ b/lib/tokenlist.cpp @@ -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); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 687c274ff..31564835f 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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; };"));