Report when using uninitialized function pointer

This commit is contained in:
Daniel Marjamäki 2010-01-23 07:57:57 +01:00
parent 8a9eba980b
commit 7b986c831d
2 changed files with 13 additions and 0 deletions

View File

@ -1706,6 +1706,11 @@ private:
}
}
if (Token::simpleMatch(tok.next(), "("))
{
use_pointer(foundError, checks, &tok);
}
if (Token::Match(tok.tokAt(-2), "[;{}] *"))
{
if (Token::simpleMatch(tok.next(), "="))

View File

@ -1716,6 +1716,14 @@ private:
"}\n");
ASSERT_EQUALS("[test.cpp:5]: (error) Uninitialized variable: x\n", errout.str());
// using uninitialized function pointer..
checkUninitVar("void foo()\n"
"{\n"
" void (*f)();\n"
" f();\n"
"}\n");
ASSERT_EQUALS("[test.cpp:4]: (error) Uninitialized variable: f\n", errout.str());
}