UnusedVariables: Fix FP for unknown variable

This commit is contained in:
Daniel Marjamäki 2018-12-13 21:37:21 +01:00
parent 092d434f91
commit 8464085535
2 changed files with 13 additions and 0 deletions

View File

@ -1170,6 +1170,11 @@ bool FwdAnalysis::isGlobalData(const Token *expr) const
bool globalData = false;
visitAstNodes(expr,
[&](const Token *tok) {
if (tok->varId() && !tok->variable()) {
// Bailout, this is probably global
globalData = true;
return ChildrenToVisit::none;
}
if (tok->originalName() == "->") {
// TODO check if pointer points at local data
globalData = true;

View File

@ -4294,6 +4294,14 @@ private:
"}"
);
ASSERT_EQUALS("", errout.str());
// Unknown variable
functionVariableUsage(
"void A::b(Date& result) {"
" result = 12;\n"
"}"
);
ASSERT_EQUALS("", errout.str());
}
};