diff --git a/lib/astutils.cpp b/lib/astutils.cpp index 70a7ccc0a..704afdd48 100644 --- a/lib/astutils.cpp +++ b/lib/astutils.cpp @@ -3177,6 +3177,12 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const return Result(Result::Type::READ); continue; } + const auto startEnd = parent->astParent()->astOperand2()->findExpressionStartEndTokens(); + for (const Token* tok2 = startEnd.first; tok2 != startEnd.second; tok2 = tok2->next()) { + if (tok2->tokType() == Token::eLambda) + return Result(Result::Type::BAILOUT); + // TODO: analyze usage in lambda + } // ({ .. }) if (hasGccCompoundStatement(parent->astParent()->astOperand2())) return Result(Result::Type::BAILOUT); diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 264591957..1213a941d 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -1432,7 +1432,7 @@ void SymbolDatabase::createSymbolDatabaseIncompleteVars() if (Token::simpleMatch(tok->next(), ")") && Token::simpleMatch(tok->next()->link()->previous(), "catch (")) continue; // Very likely a typelist - if (Token::Match(tok->tokAt(-2), "%type% ,")) + if (Token::Match(tok->tokAt(-2), "%type% ,") || Token::Match(tok->next(), ", %type%")) continue; // Inside template brackets if (Token::Match(tok->next(), "<|>") && tok->next()->link()) diff --git a/test/testother.cpp b/test/testother.cpp index 0db11da48..d154cdd45 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -8104,6 +8104,13 @@ private: " i = nullptr;\n" "}\n"); ASSERT_EQUALS("", errout.str()); + + check("int f(const std::vector& v) {\n" // #9815 + " int i = g();\n" + " i = std::distance(v.begin(), std::find_if(v.begin(), v.end(), [=](int j) { return i == j; }));\n" + " return i;\n" + "}\n"); + ASSERT_EQUALS("", errout.str()); } void redundantMemWrite() { diff --git a/test/testsymboldatabase.cpp b/test/testsymboldatabase.cpp index 163788a35..a260bddef 100644 --- a/test/testsymboldatabase.cpp +++ b/test/testsymboldatabase.cpp @@ -357,6 +357,7 @@ private: TEST_CASE(symboldatabase96); // #10126 TEST_CASE(symboldatabase97); // #10598 - final class TEST_CASE(symboldatabase98); // #10451 + TEST_CASE(symboldatabase99); // #10864 TEST_CASE(symboldatabase100); // #10174 TEST_CASE(createSymbolDatabaseFindAllScopes1); @@ -4880,6 +4881,11 @@ private: } } + void symboldatabase99() { // #10864 + check("void f() { std::map m; }"); + ASSERT_EQUALS("", errout.str()); + } + void symboldatabase100() { { GET_SYMBOL_DB("namespace N {\n" // #10174