UnusedVar: Fix FP for array arguments

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

View File

@ -1181,6 +1181,9 @@ bool FwdAnalysis::isGlobalData(const Token *expr) const
if (lhsvar->isPointer()) {
globalData = true;
return ChildrenToVisit::none;
} else if (lhsvar->isArgument() && lhsvar->isArray()) {
globalData = true;
return ChildrenToVisit::none;
} else if (lhsvar->isArgument() && (!lhstype || (lhstype->type <= ValueType::Type::VOID && !lhstype->container))) {
globalData = true;
return ChildrenToVisit::none;

View File

@ -4287,6 +4287,13 @@ private:
"}\n"
);
// TODO This works on command line.. load std.cfg? ASSERT_EQUALS("error", errout.str());
functionVariableUsage(
"void fun(short data[2]) {\n"
" data[2] = 1;\n"
"}"
);
ASSERT_EQUALS("", errout.str());
}
};