Skip inner classes in CheckAutoVariables::returnReference() (#6951)
This commit is contained in:
parent
37aec52399
commit
7bb79562e9
|
@ -407,6 +407,11 @@ void CheckAutoVariables::returnReference()
|
|||
// have we reached a function that returns a reference?
|
||||
if (tok->previous() && tok->previous()->str() == "&") {
|
||||
for (const Token *tok2 = scope->classStart->next(); tok2 && tok2 != scope->classEnd; tok2 = tok2->next()) {
|
||||
if (!tok2->scope()->isExecutable()) {
|
||||
tok2 = tok2->scope()->classEnd;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip over lambdas
|
||||
if (tok2->str() == "[" && tok2->link()->strAt(1) == "(" && tok2->link()->linkAt(1)->strAt(1) == "{")
|
||||
tok2 = tok2->link()->linkAt(1)->linkAt(1);
|
||||
|
|
|
@ -99,6 +99,7 @@ private:
|
|||
TEST_CASE(returnReferenceLiteral);
|
||||
TEST_CASE(returnReferenceCalculation);
|
||||
TEST_CASE(returnReferenceLambda);
|
||||
TEST_CASE(returnReferenceInnerScope);
|
||||
|
||||
// global namespace
|
||||
TEST_CASE(testglobalnamespace);
|
||||
|
@ -966,6 +967,19 @@ private:
|
|||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void returnReferenceInnerScope() {
|
||||
// #6951
|
||||
check("const Callback& make() {\n"
|
||||
" struct _Wrapper {\n"
|
||||
" static ulong call(void* o, const void* f, const void*[]) {\n"
|
||||
" return 1;\n"
|
||||
" }\n"
|
||||
" };\n"
|
||||
" return _make(_Wrapper::call, pmf);\n"
|
||||
"}");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void testglobalnamespace() {
|
||||
check("class SharedPtrHolder\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue