Fixed #10279 (ValueFlow/TokenList: function pointer dereference and call)
This commit is contained in:
parent
ef757e5cf9
commit
f1fff5e904
|
@ -1669,6 +1669,8 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn)
|
||||||
if (!Token::Match(tok, "{|("))
|
if (!Token::Match(tok, "{|("))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
tok = tok->astOperand1();
|
tok = tok->astOperand1();
|
||||||
|
while (tok && (tok->isUnaryOp("*") || tok->str() == "["))
|
||||||
|
tok = tok->astOperand1();
|
||||||
while (Token::simpleMatch(tok, "."))
|
while (Token::simpleMatch(tok, "."))
|
||||||
tok = tok->astOperand2();
|
tok = tok->astOperand2();
|
||||||
while (Token::simpleMatch(tok, "::")) {
|
while (Token::simpleMatch(tok, "::")) {
|
||||||
|
|
|
@ -4667,6 +4667,21 @@ private:
|
||||||
" printf(\"\", value);\n"
|
" printf(\"\", value);\n"
|
||||||
"}\n");
|
"}\n");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// function pointers
|
||||||
|
valueFlowUninit("int f (const struct FileFuncDefs *ffd) {\n" // #10279
|
||||||
|
" int c;\n"
|
||||||
|
" (*ffd->zread)(&c, 1);\n"
|
||||||
|
" return c;\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
valueFlowUninit("int foo(unsigned int code) {\n" // #10279
|
||||||
|
" int res;\n\n"
|
||||||
|
" (* (utility_table[code])) (&res);\n"
|
||||||
|
" return (res);\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitvar_ipa() {
|
void uninitvar_ipa() {
|
||||||
|
|
Loading…
Reference in New Issue