Fixed #7583 (Defect: False positive '(error) Reference to temporary returned')

This commit is contained in:
Daniel Marjamäki 2017-02-26 13:41:49 +01:00
parent c1d8fd7f13
commit f68fa72095
2 changed files with 12 additions and 1 deletions

View File

@ -482,8 +482,13 @@ void CheckAutoVariables::returnReference()
// Skip over lambdas
tok2 = skipLambda(tok2);
if (!tok2)
break;
if (!tok2 || tok2->str() != "return")
if (tok2->str() == "(")
tok2 = tok2->link();
if (tok2->str() != "return")
continue;
// return..

View File

@ -1048,6 +1048,12 @@ private:
"return s_var;\n"
"}");
ASSERT_EQUALS("", errout.str());
// #7583
check("Command& foo() {\n"
" return f([]() -> int { return 1; });\n"
"}");
ASSERT_EQUALS("", errout.str());
}
void returnReferenceInnerScope() {