Fix FP issue 8986: constArgument check warns for elements of const array (#1683)
This commit is contained in:
parent
507c7a4388
commit
941dd79f0d
|
@ -1062,7 +1062,7 @@ bool isConstVarExpression(const Token *tok)
|
||||||
}
|
}
|
||||||
if (Token::Match(tok, "( %type%"))
|
if (Token::Match(tok, "( %type%"))
|
||||||
return isConstVarExpression(tok->astOperand1());
|
return isConstVarExpression(tok->astOperand1());
|
||||||
if (Token::Match(tok, "%cop%")) {
|
if (Token::Match(tok, "%cop%|[|.")) {
|
||||||
if (tok->astOperand1() && !isConstVarExpression(tok->astOperand1()))
|
if (tok->astOperand1() && !isConstVarExpression(tok->astOperand1()))
|
||||||
return false;
|
return false;
|
||||||
if (tok->astOperand2() && !isConstVarExpression(tok->astOperand2()))
|
if (tok->astOperand2() && !isConstVarExpression(tok->astOperand2()))
|
||||||
|
|
|
@ -7574,6 +7574,21 @@ private:
|
||||||
" g(static_cast<int>(i));\n"
|
" g(static_cast<int>(i));\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// #8986
|
||||||
|
check("void f(int);\n"
|
||||||
|
"void g() {\n"
|
||||||
|
" const int x[] = { 10, 10 };\n"
|
||||||
|
" f(x[0]);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("void f(int);\n"
|
||||||
|
"void g() {\n"
|
||||||
|
" int x[] = { 10, 10 };\n"
|
||||||
|
" f(x[0]);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue