File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed
Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -1869,7 +1869,7 @@ void CheckOther::checkConstPointer()
18691869 continue ;
18701870 if (!var->isLocal () && !var->isArgument ())
18711871 continue ;
1872- if (var->isArgument () && var->scope () && var->scope ()->type == ScopeType::eLambda)
1872+ if (var->isArgument () && var->scope () && var->scope ()->type == ScopeType::eLambda && ! Token::simpleMatch (var-> scope ()-> bodyEnd , " } ( " ) )
18731873 continue ;
18741874 const Token* const nameTok = var->nameToken ();
18751875 if (tok == nameTok && var->isLocal () && !astIsRangeBasedForDecl (nameTok)) {
Original file line number Diff line number Diff line change @@ -4699,6 +4699,12 @@ class TestOther : public TestFixture {
46994699 " x();\n"
47004700 "}\n");
47014701 ASSERT_EQUALS("[test.cpp:3:27]: (style) Variable 'p' can be declared as pointer to const [constVariablePointer]\n", errout_str());
4702+
4703+ check("int f() {\n"
4704+ " int i = 0;\n"
4705+ " return [](int* p) { return *p; }(&i);\n"
4706+ "}\n");
4707+ ASSERT_EQUALS("[test.cpp:3:20]: (style) Parameter 'p' can be declared as pointer to const [constParameterPointer]\n", errout_str());
47024708 }
47034709
47044710 void constArray() {
You can’t perform that action at this time.
0 commit comments