From 21b51dd2357664e01351851e126cbcc8beb7f82d Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 4 May 2016 13:23:50 +0200 Subject: [PATCH] Check64BitPortability::pointerassignment(): Skip over lambdas (#7451) --- lib/check64bit.cpp | 2 +- test/test64bit.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/check64bit.cpp b/lib/check64bit.cpp index 144115c5d..bb3e86732 100644 --- a/lib/check64bit.cpp +++ b/lib/check64bit.cpp @@ -59,7 +59,7 @@ void Check64BitPortability::pointerassignment() for (const Token* tok = scope->classStart->next(); tok != scope->classEnd; tok = tok->next()) { // skip nested functions if (tok->str() == "{") { - if (tok->scope()->type == Scope::ScopeType::eFunction) + if (tok->scope()->type == Scope::ScopeType::eFunction || tok->scope()->type == Scope::ScopeType::eLambda) tok = tok->link(); } diff --git a/test/test64bit.cpp b/test/test64bit.cpp index 45dbd186a..dce3019fd 100644 --- a/test/test64bit.cpp +++ b/test/test64bit.cpp @@ -202,13 +202,21 @@ private: "}"); ASSERT_EQUALS("", errout.str()); - // #7247 : dont check return statements in nested functions.. + // #7247: dont check return statements in nested functions.. check("int foo() {\n" " struct {\n" " const char * name() { return \"abc\"; }\n" " } table;\n" "}"); ASSERT_EQUALS("", errout.str()); + + // #7451: Lambdas + check("const int* test(std::vector outputs, const std::string& text) {\n" + " auto it = std::find_if(outputs.begin(), outputs.end(), \n" + " [&](int ele) { return \"test\" == text; });\n" + " return nullptr;\n" + "}"); + ASSERT_EQUALS("", errout.str()); } };