parent
ef49dff488
commit
4f8329b2df
|
@ -482,6 +482,8 @@ bool FwdAnalysis::unusedValue(const Token *expr, const Token *startToken, const
|
||||||
return false;
|
return false;
|
||||||
if (hasVolatileCastOrVar(expr))
|
if (hasVolatileCastOrVar(expr))
|
||||||
return false;
|
return false;
|
||||||
|
if (Token::simpleMatch(expr, "[") && astIsContainerView(expr->astOperand1()))
|
||||||
|
return false;
|
||||||
mWhat = What::UnusedValue;
|
mWhat = What::UnusedValue;
|
||||||
Result result = check(expr, startToken, endToken);
|
Result result = check(expr, startToken, endToken);
|
||||||
return (result.type == FwdAnalysis::Result::Type::NONE || result.type == FwdAnalysis::Result::Type::RETURN) && !possiblyAliased(expr, startToken);
|
return (result.type == FwdAnalysis::Result::Type::NONE || result.type == FwdAnalysis::Result::Type::RETURN) && !possiblyAliased(expr, startToken);
|
||||||
|
|
|
@ -6000,6 +6000,11 @@ private:
|
||||||
"[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n"
|
"[test.cpp:2]: (style) Variable 'p' is assigned a value that is never used.\n"
|
||||||
"[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n",
|
"[test.cpp:3]: (style) Variable 'q' is assigned a value that is never used.\n",
|
||||||
errout.str());
|
errout.str());
|
||||||
|
|
||||||
|
functionVariableUsage("void f(std::span<int> s) {\n" // #11545
|
||||||
|
" s[0] = 0;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void localVarClass() {
|
void localVarClass() {
|
||||||
|
|
Loading…
Reference in New Issue