Extend scope of afterCondition until end of function
This commit is contained in:
parent
7d9220e96c
commit
07d8cb4f01
|
@ -4232,7 +4232,10 @@ struct ValueFlowConditionHandler {
|
||||||
// TODO: constValue could be true if there are no assignments in the conditional blocks and
|
// TODO: constValue could be true if there are no assignments in the conditional blocks and
|
||||||
// perhaps if there are no && and no || in the condition
|
// perhaps if there are no && and no || in the condition
|
||||||
bool constValue = false;
|
bool constValue = false;
|
||||||
forward(after, top->scope()->bodyEnd, cond.vartok, values, constValue);
|
const Scope* scope = top->scope();
|
||||||
|
while(scope->nestedIn && scope->type != Scope::eFunction)
|
||||||
|
scope = scope->nestedIn;
|
||||||
|
forward(after, scope->bodyEnd, cond.vartok, values, constValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -262,7 +262,7 @@ private:
|
||||||
" }\n"
|
" }\n"
|
||||||
" tok->str();\n"
|
" tok->str();\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
TODO_ASSERT_EQUALS("[test.cpp:5] -> [test.cpp:3]: (warning, inconclusive) Possible null pointer dereference: tok - otherwise it is redundant to check it against null.\n", "", errout.str());
|
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:5]: (warning) Either the condition 'tok' is redundant or there is possible null pointer dereference: tok.\n", errout.str());
|
||||||
|
|
||||||
check("int foo(const Token *tok)\n"
|
check("int foo(const Token *tok)\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue