From f5528ec3fcb68defd4e86491270513f07c138a9a Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:02:16 +0200 Subject: [PATCH 1/3] Update symboldatabase.cpp --- lib/symboldatabase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/symboldatabase.cpp b/lib/symboldatabase.cpp index 40c18bdbff6..0ec65c466ca 100644 --- a/lib/symboldatabase.cpp +++ b/lib/symboldatabase.cpp @@ -3066,7 +3066,7 @@ static bool checkReturns(const Function* function, bool unknown, bool emptyEnabl { if (!function) return false; - if (function->type != Function::eFunction && function->type != Function::eOperatorEqual) + if (function->type != Function::eFunction && function->type != Function::eOperatorEqual && function->type != Function::eLambda) return false; const Token* defStart = function->retDef; if (!defStart) From 9ef29a20ae405a1a69e85ef9af57b6a35fbca3ed Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:03:26 +0200 Subject: [PATCH 2/3] Update testother.cpp --- test/testother.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/testother.cpp b/test/testother.cpp index 48e9aedecc9..6f338f4d6db 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3636,6 +3636,16 @@ class TestOther : public TestFixture { " g(r[0] * 2);\n" "}\n"); ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'r' can be declared as reference to const\n", errout_str()); + + check("std::iostream& get();\n" // #12940 + "std::iostream & Fun() {\n" + " auto lam = []() -> std::iostream& {\n" + " std::iostream& ios = get();\n" + " return ios;\n" + " };\n" + " return lam();\n" + "}\n"); + ASSERT_EQUALS("", errout_str()); } void constParameterCallback() { From 8850de3c9351831a2932becf2dc05d99ab6fbaa9 Mon Sep 17 00:00:00 2001 From: chrchr-github <78114321+chrchr-github@users.noreply.github.com> Date: Tue, 16 Jul 2024 14:15:49 +0200 Subject: [PATCH 3/3] Format [skip ci] --- test/testother.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testother.cpp b/test/testother.cpp index 6f338f4d6db..52b89b622ee 100644 --- a/test/testother.cpp +++ b/test/testother.cpp @@ -3638,7 +3638,7 @@ class TestOther : public TestFixture { ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'r' can be declared as reference to const\n", errout_str()); check("std::iostream& get();\n" // #12940 - "std::iostream & Fun() {\n" + "std::iostream& Fun() {\n" " auto lam = []() -> std::iostream& {\n" " std::iostream& ios = get();\n" " return ios;\n"