UnusedVariables: Fix FP for unknown variable
This commit is contained in:
parent
092d434f91
commit
8464085535
|
@ -1170,6 +1170,11 @@ bool FwdAnalysis::isGlobalData(const Token *expr) const
|
||||||
bool globalData = false;
|
bool globalData = false;
|
||||||
visitAstNodes(expr,
|
visitAstNodes(expr,
|
||||||
[&](const Token *tok) {
|
[&](const Token *tok) {
|
||||||
|
if (tok->varId() && !tok->variable()) {
|
||||||
|
// Bailout, this is probably global
|
||||||
|
globalData = true;
|
||||||
|
return ChildrenToVisit::none;
|
||||||
|
}
|
||||||
if (tok->originalName() == "->") {
|
if (tok->originalName() == "->") {
|
||||||
// TODO check if pointer points at local data
|
// TODO check if pointer points at local data
|
||||||
globalData = true;
|
globalData = true;
|
||||||
|
|
|
@ -4294,6 +4294,14 @@ private:
|
||||||
"}"
|
"}"
|
||||||
);
|
);
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// Unknown variable
|
||||||
|
functionVariableUsage(
|
||||||
|
"void A::b(Date& result) {"
|
||||||
|
" result = 12;\n"
|
||||||
|
"}"
|
||||||
|
);
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue