Skip to content

Commit 8ec2a65

Browse files
Fix #12940 Lambda type const wrongly suggested (#6605)
1 parent 4e35173 commit 8ec2a65

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/symboldatabase.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3066,7 +3066,7 @@ static bool checkReturns(const Function* function, bool unknown, bool emptyEnabl
30663066
{
30673067
if (!function)
30683068
return false;
3069-
if (function->type != Function::eFunction && function->type != Function::eOperatorEqual)
3069+
if (function->type != Function::eFunction && function->type != Function::eOperatorEqual && function->type != Function::eLambda)
30703070
return false;
30713071
const Token* defStart = function->retDef;
30723072
if (!defStart)

test/testother.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3636,6 +3636,16 @@ class TestOther : public TestFixture {
36363636
" g(r[0] * 2);\n"
36373637
"}\n");
36383638
ASSERT_EQUALS("[test.cpp:6]: (style) Variable 'r' can be declared as reference to const\n", errout_str());
3639+
3640+
check("std::iostream& get();\n" // #12940
3641+
"std::iostream& Fun() {\n"
3642+
" auto lam = []() -> std::iostream& {\n"
3643+
" std::iostream& ios = get();\n"
3644+
" return ios;\n"
3645+
" };\n"
3646+
" return lam();\n"
3647+
"}\n");
3648+
ASSERT_EQUALS("", errout_str());
36393649
}
36403650

36413651
void constParameterCallback() {

0 commit comments

Comments
 (0)