Fixed #8949 (False Positive: Variable 'f' is assigned a value that is never used.)
This commit is contained in:
parent
d35a26c6f0
commit
8c07be136a
|
@ -1108,6 +1108,13 @@ struct FwdAnalysis::Result FwdAnalysis::checkRecursive(const Token *expr, const
|
||||||
// TODO
|
// TODO
|
||||||
return Result(Result::Type::BAILOUT);
|
return Result(Result::Type::BAILOUT);
|
||||||
|
|
||||||
|
if (const Token *lambdaEndToken = findLambdaEndToken(tok)) {
|
||||||
|
tok = lambdaEndToken;
|
||||||
|
const Result lambdaResult = checkRecursive(expr, lambdaEndToken->link()->next(), lambdaEndToken, exprVarIds, local);
|
||||||
|
if (lambdaResult.type == Result::Type::READ || lambdaResult.type == Result::Type::BAILOUT)
|
||||||
|
return lambdaResult;
|
||||||
|
}
|
||||||
|
|
||||||
if (Token::Match(tok, "return|throw")) {
|
if (Token::Match(tok, "return|throw")) {
|
||||||
// TODO: Handle these better
|
// TODO: Handle these better
|
||||||
// Is expr variable used in expression?
|
// Is expr variable used in expression?
|
||||||
|
|
|
@ -181,7 +181,7 @@ private:
|
||||||
TEST_CASE(localvarFuncPtr); // #7194
|
TEST_CASE(localvarFuncPtr); // #7194
|
||||||
TEST_CASE(localvarAddr); // #7477
|
TEST_CASE(localvarAddr); // #7477
|
||||||
TEST_CASE(localvarDelete);
|
TEST_CASE(localvarDelete);
|
||||||
TEST_CASE(localvarReturnCallLambda); // #8941
|
TEST_CASE(localvarLambda); // #8941
|
||||||
|
|
||||||
TEST_CASE(localvarCppInitialization);
|
TEST_CASE(localvarCppInitialization);
|
||||||
TEST_CASE(localvarCpp11Initialization);
|
TEST_CASE(localvarCpp11Initialization);
|
||||||
|
@ -4233,12 +4233,19 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void localvarReturnCallLambda() {
|
void localvarLambda() {
|
||||||
functionVariableUsage("int foo() {\n"
|
functionVariableUsage("int foo() {\n"
|
||||||
" auto f = []{return 1};\n"
|
" auto f = []{return 1};\n"
|
||||||
" return f();\n"
|
" return f();\n"
|
||||||
"}");
|
"}");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
functionVariableUsage("int foo() {\n"
|
||||||
|
" auto f = []{return 1};\n"
|
||||||
|
" auto g = []{return 1};\n"
|
||||||
|
" return f() + g();\n"
|
||||||
|
"}");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void localvarCppInitialization() {
|
void localvarCppInitialization() {
|
||||||
|
|
Loading…
Reference in New Issue