Fixed #10279 (ValueFlow/TokenList: function pointer dereference and call)

This commit is contained in:
Daniel Marjamäki 2021-05-20 13:54:00 +02:00
parent ef757e5cf9
commit f1fff5e904
2 changed files with 17 additions and 0 deletions

View File

@ -1669,6 +1669,8 @@ const Token * getTokenArgumentFunction(const Token * tok, int& argn)
if (!Token::Match(tok, "{|("))
return nullptr;
tok = tok->astOperand1();
while (tok && (tok->isUnaryOp("*") || tok->str() == "["))
tok = tok->astOperand1();
while (Token::simpleMatch(tok, "."))
tok = tok->astOperand2();
while (Token::simpleMatch(tok, "::")) {

View File

@ -4667,6 +4667,21 @@ private:
" printf(\"\", value);\n"
"}\n");
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() {